今天花了大半天的时间才把tomcat5.5.17下的连接池问题搞定。趁着思路还没被打断,把有些总结记录下来。
there is a datasourceProject,and there is a context file under %TOMCAT_HOME%/conf/Catalina/localhost/ ,where TOMCAT_HOME is the dirctory tomcat is installed.
(1) org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null'
..........
Caused by: java.sql.SQLException: No suitable driver
in this senario what we configure is :
in server.xml i add
<Resource auth="Container" name="jdbc/hinge" type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/hinge">
<parameter>
<name>factory</name>
<value>org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory</value>
</parameter>
<parameter>
<name>maxWait</name>
<value>5000</value>
</parameter>
<parameter>
<name>maxActive</name>
<value>4</value>
</parameter>
<parameter>
<name>password</name>
<value></value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc:mysql://localhost/hinge</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>com.mysql.jdbc.Driver</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>2</value>
</parameter>
<parameter>
<name>username</name>
<value>root</value>
</parameter>
</ResourceParams>
and i add <ResourceLink global="jdbc/hinge" name="jdbc/hinge" type="javax.sql.DataSourcer"/> in datasourceProject.xml。
(2) i move <Resouce> and <ResourceParames> to datasourceProject.xml, it did not work well also.
(3) at last i change the form of the configuration, it apprears as following:
the right configuration:
<Context path="datasourceProject" reloadable="true" docBase="E:/6+1/datasourceProject" workDir="E:/6+1/datasourceProject/work" >
<Resource auth="Container" description="DB2 Datasource" name="jdbc/hinge" type="javax.sql.DataSource"
factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory" url="jdbc:mysql://localhost/hinge"
driverClassName="com.mysql.jdbc.Driver"
username="root"
password=""
maxActive="20"
maxIdle="10"
maxWait="-1" /
>
</Context>
at last , i change the <Resource> in (1) to the form as in (3), it runs well.
note: there is a discussion in http://www.theserverside.com/discussions/thread.tss?thread_id=29795