Tomcat连接池问题

04-06-05 lluuoo
源代码:

try {

Context ctx = new InitialContext();

if (ctx == null) {

throw new Exception("Context Look Up Error");

}

DataSource dsource = (DataSource)ctx.lookup("java:comp/env/jdbc/cartDB");

if (dsource != null) {

System.out.println("---------------------------------------------------");

con = dsource.getConnection();

}

}

。。。

错误如下:

2004-6-4 23:32:41 org.apache.coyote.http11.Http11Protocol start

信息: Starting Coyote HTTP/1.1 on port 8083

------------------------------------------------------------

数据连接池连接错误:Cannot load JDBC driver class 'null'

java.sql.SQLException: Cannot load JDBC driver class 'null'

at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:529)

at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:312)

at flowershop.DBConnection.initDataSource_Connection(DBConnection.java:89)

at flowershop.DBConnection.<init>(DBConnection.java:29)

DataSource对象已经生成,就是不能获得连接,请问这是什么原因造成的?

huzhigang
2004-06-07 08:44
Cannot load JDBC driver class 'null'

这句说明你指定的jdbc driver类有问题

lluuoo
2004-06-07 13:45
还是不太明白,能否更详细一点,大哥!

huzhigang
2004-06-07 14:21
你说Datasource对象已经生成.但从错误提示来看,我觉得没有产生这个对象.dbcp包也已经报错了.你确认一下你的dbcp配置是否正确.dbcp我原来也用过.应该很容易配置的.请你再检查一下.

猜你喜欢