Topic: 高手急救我的tomcat连接池出不来?

  Print this page

1.高手急救我的tomcat连接池出不来? Copy to clipboard
Posted by: cdtdx
Posted on: 2004-10-18 17:23

请各位高手帮帮我,我弄不出来,急得要哭了。

出现的问题如下:
getDataSource() error: org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null'

Mysql init error: java.lang.NullPointerException
出现问题的代码:
private void getDataSource() {
try {
Context ctx = new InitialContext();
if (ctx == null)
throw new Exception("Boom - No Context");

DataSource ds =
(DataSource) ctx.lookup("java:comp/env/jdbc/myDB");


if (ds != null) {
conn = ds.getConnection();
}
else
System.out.println("can't look up jndi!");

} catch (Exception e) {
System.err.println("getDataSource() error: " + e);

}
}

web.xml如下:
<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/myDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>

server.xml如下:
<Context path="/register" docBase="D:\downloads\chapter2\SimpleRegister\defaultroot" debug="5" reloadable="true" crossContext="true">

<Resource name="jdbc/myDB" auth="Container" type="javax.sql.DataSource">
<ResourceParams name="jdbc/myDB">
<parameter>
   <name>factory</name>
   <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
  </parameter>
  <parameter>
   <name>maxActive</name>
   <value>100</value>
  </parameter>
  <parameter>
   <name>maxIdle</name>
   <value>30</value>
  </parameter>
  <parameter>
   <name>maxWait</name>
   <value>10000</value>
  </parameter>
  <parameter>
   <name>username</name>
   <value>root</value>
  </parameter>
  <parameter>
   <name>password</name>
   <value></value>
  </parameter>
  <parameter>
   <name>driverClassName</name>
   <value>com.mysql.jdbc.Driver</value>
  </parameter>
  <parameter>
   <name>url</name>
   <value>jdbc:mysql://202.115.30.220:3306/signup</value>
  </parameter>
</ResourceParams>
</Resource>
</Context>

2.Re:高手急救我的tomcat连接池出不来? [Re: cdtdx] Copy to clipboard
Posted by: jbwang
Posted on: 2004-10-18 23:07

url需要大写?

3.Re:高手急救我的tomcat连接池出不来? [Re: cdtdx] Copy to clipboard
Posted by: china2004
Posted on: 2004-11-02 22:52

请问你是否已经把MySQL的驱动包放在Tomcat->Common->lib下面?


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923