简体   繁体   English

无法为连接URL创建类'com.mysql.jdbc.Driver'的JDBC驱动程序

[英]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: 我发现的明显答案是:

  • Database URL malformed? 数据库URL格式错误? - checked and OK. -检查并确定。
  • MySQL driver in classpath? 类路径中的MySQL驱动程序? Yes- jar is in $TOMCAT_HOME/lib 是-jar位于$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的认可文件夹中,该文件夹可能是

  • TOMCAT_HOME/endorsed or TOMCAT_HOME /认可或
  • TOMCAT_HOME/shared/lib TOMCAT_HOME /共享/ lib中

Check your Tomcat setup. 检查您的Tomcat设置。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法为连接URL&#39;jdbc:mysql // localhost:3306 /创建类&#39;com.mysql.jdbc.Driver&#39;的JDBC驱动程序 - Cannot create JDBC driver of class 'com.mysql.jdbc.Driver' for connect URL 'jdbc:mysql//localhost:3306/ 如何解决“无法为连接URL创建类&#39;com.mysql.jdbc.Driver&#39;的JDBC驱动程序” - How to resolve “Cannot create JDBC driver of class 'com.mysql.jdbc.Driver' for connect URL” Spring + Hibernate + Maven:j无法为连接URL“ jdbc:mysql // localhost:3306 / test”创建类“ com.mysql.jdbc.Driver”的JDBC驱动程序 - Spring + Hibernate + Maven: jCannot create JDBC driver of class 'com.mysql.jdbc.Driver' for connect URL 'jdbc:mysql//localhost:3306/test' 无法加载驱动程序 class:com.mysql.jdbc.Driver Spring - Cannot load driver class: com.mysql.jdbc.Driver Spring 未找到指定的 JDBC 驱动程序 com.mysql.jdbc.Driver 类 - Specified JDBC Driver com.mysql.jdbc.Driver class not found 无法加载 JDBC 驱动程序类 [com.mysql.jdbc.Driver] - Could not load JDBC driver class [com.mysql.jdbc.Driver] 找不到类com.mysql.jdbc.Driver - Class not found com.mysql.jdbc.Driver 无法加载JDBC驱动程序类&#39;com.mysql.jdbc.Driver&#39;Tomcat 8和Eclipse - Cannot load JDBC driver class 'com.mysql.jdbc.Driver' Tomcat 8 & Eclipse 驱动程序“ com.mysql.jdbc.Driver”不支持URL“空” - Driver “com.mysql.jdbc.Driver” does not support the url “null” 无法加载驱动程序 class com.mysql.Z84BEFFD3A0D49636A58CE6080CAA87C7 - Failed to load driver class com.mysql.jdbc.Driver
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM