数据库连接池问题(Tomcat5.0.18+SQL Server2000)
我已经写好了在server.xml中添加了
<Resource name= "jdbc/TestTS "
type= "javax.sql.DataSource " driverClassName= "com.microsoft.jdbc.sqlserver.SQLServerDriver "
maxIdle= "2 "
maxWait= "5000 "
username= "sa "
password= " " url= "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=helpContract " maxActive= "4 ">
</Resource>
在Catalina/localhost下也创建了TestTS.xml
<?xml version= "1.0 " encoding= "UTF-8 "?>
<Context>
<Resource name= "jdbc/TestTS "
type= "javax.sql.DataSource " driverClassName= "com.microsoft.jdbc.sqlserver.SQLServerDriver "
maxIdle= "2 "
maxWait= "5000 "
username= "sa "
password= " "
url= "jdbc:microsoft:sqlserver://localhost;DatabaseName=helpContract " maxActive= "4 ">
</Resource>
</Context>
也在web.xml中添加了
<resource-ref>
<description> sqlserverDB Connection </description>
<res-ref-name> jdbc/TestTS </res-ref-name>
<res-type> javax.sql.DataSource </res-type>
<res-auth> Container </res-auth>
</resource-ref>
但运行时出现如下信息:
已经获得DataSource org.apache.commons.dbcp.BasicDataSource@1a01f91
org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class ' ' for connect URL 'null ', cause: No suitable driver
从No suitable driver来看应该是没有合适的驱动,但我明明已经将
msbase.jar,mssqlserver.jar,msutil.jar分别考到common\lib和TestTS\WEB-INF下了亚,难道是配置文件有问题?大家帮忙看看
------解决方案--------------------TestTS.xml
下面的url= "jdbc:microsoft:sqlserver://localhost;DatabaseName=helpContract " 错了
要加上端口号1433
------解决方案------------