JiveJdon3.0 为何连不上MySQL 数据库?

05-02-28 bolaila

我看了几天这个版本的有关数据库连接的源码,但是仍未能解决空指针的问题,真无奈v=v !

希望各位指点:

经测试:jive 中的连接数据库代码都是OK 的,但就是连接不上数据库。

下面是我的测试代码:

package myCom.test;

import java.io.*;

import myCom.util.XMLParse;

import java.sql.*;

import java.util.*;

public class xmlTest

{

public static void main(String[] args)

{

Connection[] connPool = null;

Statement stmt = null;

ResultSet rst = null;

try

{

XMLParse parse = new XMLParse("E:\\javaSample\\DataAccess\\XMLFileParse\\jive.xml");

//parse.updateElement("root.one.a.b","one text");

String url = parse.getElementText("jive.database.defaultProvider.serverURL");

String driver = parse.getElementText("jive.database.defaultProvider.driver");

String userName = parse.getElementText("jive.database.defaultProvider.username");

String password = parse.getElementText("jive.database.defaultProvider.password");

//String minConn = parse.getElementText("jive.database.defaultProvider.minConnections");

//String maxConn = parse.getElementText("jive.database.defaultProvider.maxConnections");

System.out.println ("driver:"+driver+"\n url"+url+"\n userName:"+userName+"\n password :"+password);

java.util.Date now = new java.util.Date();

int loop = 5;

connPool = new Connection[5];

for (int i = 0; i<loop; i++)

{

try

{

Class.forName(driver).newInstance();

// Connection cc = DriverManager.getConnection(url,userName,password);

connPool = DriverManager.getConnection(url,userName,password);

// System.out.println(now.toString() + " Opening connection " + String.valueOf(i) +

// " " + cc.toString() + ":");

System.out.println(now.toString() + " Opening connection " + String.valueOf(i) +

" " + connPool.toString() + ":");

}

catch (ClassNotFoundException cnfe)

{

System.out.println ("Exception for createConn()::");

cnfe.printStackTrace();

throw new SQLException(cnfe.getMessage());

}

}

//one

String sq="select * from jiveid";

stmt = connPool[1].createStatement();

rst = stmt.executeQuery(sq);

while(rst.next())

{

System.out.println ("idType::"+rst.getInt("idType"));

System.out.println ("id::"+rst.getInt("id"));

}

System.out.println ("=====**************==========\n\n");

//two

String sql = "select * from jiveuser";

stmt = connPool[2].createStatement();

rst = stmt.executeQuery(sql);

while(rst.next())

{

System.out.println ("name::"+rst.getString("name"));

System.out.println ("userName::"+rst.getString("username"));

}

System.out.println ("=====**************==========\n\n");

for (int i = 0; i<loop; i++)

{

try

{

if(!connPool.isClosed())

{

System.out.println ("close the connetion:"+connPool.toString());

connPool.close();

}

}

catch (Exception ex)

{

}

}

}

catch (Exception ex) {

ex.printStackTrace();

}

}

}

输出完全没问题的,这也是JiveJdon3.0 使用的数据库连接方法。

运行提示空指针异常,输出的日志记录如下:

Attempt (1 of 5) failed to create new connections set at startup:

java.sql.SQLException: Communication failure during handshake. Is there a server running on 127.0.0.1:3306?

。。。。。

还望各位不惜指教,谢谢!

bolaila
2005-03-04 09:05

各位老大,有成功配置好Jive 论坛的么?

可否分享一下您的经验?

帮帮我们这些初级的嘛!

昔日怀旧
2005-03-29 17:16

是呀,大家详细点说说,我上周末买了这本书,

可是他介绍的是linux而不是windows呀

win才是我们现在的主流呀・

按照他的说法安装行不通呀

xiekelinux
2005-04-22 16:29

大哥.你的JiveJdon3.0 是在哪儿下载的?我怎么下不到?