I have generated a CRUD application (in the trail version).
When I run it (in myeclipse tomcat) i get JDBC Exception:org.apache.commons.dbcp.SQLNestedException: Cannot load JDBC driver class 'com.mysql.jdbc.Driver'
I have the dependency in my pom:
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.17</version>
</dependency>
I 开发者_C百科also see the jar in myeclipse tomcat:
/home/username/Workspaces/MyEclipse for Spring 9/.metadata/.me_tcat/webapps/Test1/WEB-INF/lib
This is my tomcat TREE
http://pastie.org/2464591org.apache.commons.dbcp.SQLNestedException
You're apparently using Tomcat's builtin DBCP connection pooled datasource by a <Resource>
configuration in context.xml
. That's perfectly fine. But since it's Tomcat who is managing the datasource (and thus not your webapp!), the JDBC driver JAR file needs to be supplied to Tomcat (and thus not to your webapp!).
Drop the JAR file in Tomcat's /lib
folder and this exception should disappear. If you can't afford moving the JAR due to some (silly) business restrictions or something, then you should create the datasource yourself in the webapp. A ServletContextListener
is a good place.
精彩评论