简体   繁体   English

请让我知道与jdk 1.7兼容的任何MySQL版本

[英]Please let me know any MySQL version which works with jdk 1.7

I Installed JDK 1.7 and tried to connect to different MySQL database and Connector/J versions. 我安装了JDK 1.7,并尝试连接到不同的MySQL数据库和Connector / J版本。 But every time, I'm getting the following error when loading the driver: 但是每次加载驱动程序时,都会出现以下错误:

Exception in thread "main" java.lang.ExceptionInInitializerError
 at java.lang.Class.forName0(Native Method)
 at java.lang.Class.forName(Class.java:186)
 at jdbc.JDBC.main(JDBC.java:24)
Caused by: java.lang.RuntimeException: Uncompilable source code - com.mysql.jdbc.NonRegisteringDriver is not abstract and does not override abstract method getParentLogger() in java.sql.Driver
 at com.mysql.jdbc.NonRegisteringDriver.<clinit>(NonRegisteringDriver.java:69)
 ... 3 more

Which MySQL driver version is compatible with JDK 1.7? 哪个MySQL驱动程序版本与JDK 1.7兼容?

The exception message says this: 异常消息说明:

"Caused by: java.lang.RuntimeException: Uncompilable source code - com.mysql.jdbc.NonRegisteringDriver is not abstract and does not override abstract method getParentLogger() in java.sql.Driver" “由以下原因引起:java.lang.RuntimeException: 无法编译的源代码 -com.mysql.jdbc.NonRegisteringDriver不是抽象的,并且不会覆盖java.sql.Driver中的抽象方法getParentLogger()”

I think that the problem is that you (or someone else) have/has attempted to build the JDBC driver from source code and not noticed that there were compilation errors, and assembled the resulting broken ".class" files into a JAR file. 我认为问题在于您(或其他人)已经尝试从源代码构建JDBC驱动程序,而没有注意到存在编译错误,并将产生的损坏的“ .class”文件组装到JAR文件中。


The standard Connector/J driver JAR files from the MySQL website should work with Java 7. Certainly, I've never experienced any problems like this with them. MySQL网站上的标准Connector / J驱动程序JAR文件应与Java 7配合使用。当然,我从未遇到过类似的问题。


I'm more inclined to believe the evidence that I can see in the Exception message than your assurance that everything is "perfect": 我更倾向于相信我可以在“异常”消息中看到的证据,而不是您对一切都“完美”的保证:

  • Are you sure that you are using a Connector/J JAR file that you downloaded from the MySQL Website? 您确定使用从MySQL网站下载的Connector / J JAR文件吗?

  • Did you check that MD5 checksum to make sure that you got the real thing? 您是否检查了MD5校验和以确保您得到了真实的东西?

  • If you built from source, did you read the stuff in the docs/readme.txt about the JRE versions required to build correctly? 如果是从源代码构建的,您是否阅读了docs / readme.txt中有关正确构建所需JRE版本的内容?

  • Do you have some other (broken) copy of the drivers on your application's classpath? 您的应用程序的类路径上是否有其他(损坏的)驱动程序副本?

"Caused by: java.lang.RuntimeException: Uncompilable source code -
com.mysql.jdbc.NonRegisteringDriver is not abstract and does not override
abstract method getParentLogger() in java.sql.Driver"

The method getParentLogger() was introduced to the Driver interface in Java 1.7. 方法getParentLogger()被引入Java 1.7的Driver接口中。

Find a MySQL driver that supports Java 1.7 or switch back to Java 1.6. 发现,支持Java 1.7或切换回Java 1.6 MySQL驱动程序。

Edit: Additional info: 编辑:附加信息:

I tested JDK 1.7.10 and a driver Jar named: mysql-connector-java-5.1.6-bin.jar 我测试了JDK 1.7.10和驱动jar命名为: mysql-connector-java-5.1.6-bin.jar

Using the following code: 使用以下代码:

public static void main(String[] args) throws ClassNotFoundException,
        InstantiationException, IllegalAccessException, SQLException {
    System.out.println("Java version: "
            + System.getProperty("java.version"));
    Driver driver = (Driver) Class.forName("com.mysql.jdbc.Driver")
            .newInstance();
    System.out.println("JDBC driver: " + driver.getMajorVersion() + "."
            + driver.getMinorVersion());
    Connection connection = DriverManager.getConnection(
            "jdbc:mysql://localhost:3306/DBNAME", "user", "pass");
    System.out.println("Connection: " + connection.getClass().getName());
}

It gives the following output: 它给出以下输出:

Java version: 1.7.0_10
JDBC driver: 5.1
Connection: com.mysql.jdbc.JDBC4Connection

Possibly you have also a problem with the JDK/JRE Installation. 可能您的JDK / JRE安装也有问题。 When installing the JDK, it wants to update SQL drivers. 安装JDK时,它想更新SQL驱动程序。
You might give it a try to uninstall and re-install the JDK. 你可以给它一个尝试卸载并重新安装JDK。

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

相关问题 哪个版本的Drools与JDK 1.7一起使用 - Which version of Drools to use with JDK 1.7 java -version告诉我8但jdk是1.7 - OSX 10.9.x - java -version tells me 8 but jdk is 1.7 - OSX 10.9.x 请让我知道我的Java代码是否正确? - Please let me know whether my java code is right or not? 请让我知道如何在java的构造函数中将值作为3级传递? - Please let me know how to pass the values as 3 level in constructors in java? 具有https tsa的JDK 1.7 jarsigner不再有效 - JDK 1.7 jarsigner with https tsa no longer works JDK版本在Android Studio中自动重置为1.7 - Jdk version automatically resets to 1.7 in android studio 它显示客户已定义的错误。请让我知道发生了什么错误以及如何纠正它 - It show the error that Customer is already defined.Please let me know whats wrong and how to correct it Mysql Connector在JDK 1.7上不适用于Eclipse Juno - Mysql Connector not working for Eclipse Juno on JDK 1.7 有人可以帮助我了解org.reflections.Reflections jar上的jdk版本兼容性 - can someone help me to know jdk version compatibility on org.reflections.Reflections jar 升级spring引导版本时,卡住如下错误。 请让我知道如何解决这个问题 - While upgrading the spring boot version, stuck with the following error. Pls let me know how to solve this
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM