出错信息:Cannot load JDBC driver class 'com.mysql.jdbc.Driver' server.xml部分内容:
<Resource name="jdbc/bbs" auth="Container" type="javax.sql.DataSource" maxActive="50" maxIdle="5" maxWait="3000" username="root" password="root" driverClassName="com.mysql.jdbc.Driver"url="jdbc:mysql://localhost:3306/bbs"/>
<parameter>
<name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter>web.xml部分内容: <resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/bbs</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>测试代码为:
Connection conn = null;
DataSource ds = null;
Context ctx = new InitialContext();
ds = (DataSource) ctx.lookup("java:comp/env/jdbc/bbs");
if (ds != null) {
conn = ds.getConnection();
}
return conn;
我有一个"mysql-connector-java-3.2.0-alpha-bin.jar"的驱动包放到了WEB-INF\lib下
还是出现了:Cannot load JDBC driver class 'com.mysql.jdbc.Driver'的错误
如果我不用连接池就不会出现这种错误!!有谁知道怎么解决吗????
<Resource name="jdbc/bbs" auth="Container" type="javax.sql.DataSource" maxActive="50" maxIdle="5" maxWait="3000" username="root" password="root" driverClassName="com.mysql.jdbc.Driver"url="jdbc:mysql://localhost:3306/bbs"/>
<parameter>
<name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter>web.xml部分内容: <resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/bbs</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>测试代码为:
Connection conn = null;
DataSource ds = null;
Context ctx = new InitialContext();
ds = (DataSource) ctx.lookup("java:comp/env/jdbc/bbs");
if (ds != null) {
conn = ds.getConnection();
}
return conn;
我有一个"mysql-connector-java-3.2.0-alpha-bin.jar"的驱动包放到了WEB-INF\lib下
还是出现了:Cannot load JDBC driver class 'com.mysql.jdbc.Driver'的错误
如果我不用连接池就不会出现这种错误!!有谁知道怎么解决吗????
conf 中server.xml中方
<Context path="/simple" docBase="simple" debug="5" reloadable="true" crossContext="true">
<Logger className="org.apache.catalina.logger.FileLogger" prefix="localhost_DBCP_log." suffix=".txt" timestamp="true"/>
<Resource name="jdbc/TestDB" auth="Container" type="javax.sql.DataSource" maxActive="100" maxIdle="30" maxWait="10000" username="root" password="860317" driverClassName="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/bookstore?autoReconnect=true"/>
</Context>
web中就放你那个
一定行的 我试过
com.mysql.jdbc.Driver是新的