[英]Cannot create JDBC driver of class 'com.mysql.jdbc.Driver' for connect URL
I am getting the above exception, and I don't know why. 我遇到了以上例外情况,我不知道为什么。 Here is some more information:
这里是一些更多信息:
Cannot create JDBC driver of class 'com.mysql.jdbc.Driver' for connect URL 'jdbc:mysql://localhost:3306/staffing_2014'
I am using Spring. 我正在使用Spring。 In the Spring application context, I have the following dataSource:
在Spring应用程序上下文中,我具有以下数据源:
<jee:jndi-lookup id="dataSource"
jndi-name="jdbc/StaffingDB"
expected-type="javax.sql.DataSource" />
It seems to read the database URL and credentials OK from tomcat's context.xml
: 似乎从tomcat的
context.xml
读取数据库URL和凭据可以:
<Resource name="jdbc/StaffingDB" auth="Container" type="javax.sql.DataSource"
maxActive="100" maxIdle="30" maxWait="10000"
username="xxx" password="yyy" driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/staffing_2014"/>
Before anyone suggests Googling it, I have. 在有人建议谷歌搜索之前,我已经知道了。 The obvious answers I've found have been:
我发现的明显答案是:
$TOMCAT_HOME/lib
$TOMCAT_HOME/lib
Any other suggesions? 还有其他建议吗?
EDIT - way down the bottom: 编辑-向下的方式:
java.sql.SQLException: No suitable driver
java.sql.DriverManager.getDriver(DriverManager.java:279)
org.apache.tomcat.dbcp.dbcp.BasicDataSource.createConnectionFactory(BasicDataSource.java:1437)
org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1371)
org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044)
org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:111)
org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:77)
What version of Tomcat are you using? 您正在使用哪个版本的Tomcat? In some Tomcats (T5),
TOMCAT_HOME/lib
may not be the right location. 在某些Tomcat(T5)中,
TOMCAT_HOME/lib
可能不是正确的位置。 You have to put the driver in Tomcat's endorsed folder which could be 您必须将驱动程序放入Tomcat的认可文件夹中,该文件夹可能是
Check your Tomcat setup. 检查您的Tomcat设置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.