tomcat jdbc pool 配置
环境:tomcat7; jdk1.8; MySQL-5.7.17 Community Server (GPL); Oxygen Release (4.7.0)
当跑jndi项目时抛出:org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class ” for connect URL ‘jdbc:mysql://localhost:3306/’
检查配置
1、在$CATALINA_HOME/lib下加入驱动包mysql-connector-java-5.1.30-bin.jar
2、在工程对应的context.xml中添加
<Resource name="jdbc/pager02"
auth="Container"
type="javax.sql.DataSource"
username="root"
password="iampig??110"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/test_msg"
maxActive="20"
maxIdle="15"/>
3、检查项目中web.xml里面的配置是否和context.xml实例名一样
<resource-ref>
<description>DB connect pool</description>
<res-ref-name>jdbc/pager02</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
4.数据库url是否写错,不是jdbc:mysql://localhost:3306/ (properties文件拷过来的),而是jdbc:mysql://localhost:3306/test_msg