I have a java program that used to work and then it stopped working.
The error that I am getting is
java.sql.SQLException: No suitable driver found for jdbc:mysql://feldspar:3306/sndm
I looked into what changed, and one thing that changed was the version of mysql-connector-java
. In the last version that worked, the pom.xml
contained
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.16</version>
<optional>true</optional>
</dependency>
and in the version that did NOT work the pom.xml
contained
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.33</version>
<optional>true</optional>
</dependency>
(Note that the dependency is optional because I use maven-shade-plugin
to build different JARs for different databases.)
So I tried reverting to 8.0.16
, and it started working again.
So then I tested with different versions of the driver, and I found that with 8.0.30
it worked, but with 8.0.31
, 8.0.32
and 8.0.33
it does not work.
My code does NOT call Class.forName()
or DriverManager.registerDriver()
.
My understanding is that these methods are no longer required,
and that JDBC should find the correct driver based on the URI.
Is there a known issue with mysql-connector-java
version 8.0.33
?
p.s.
I am using Java 11
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<mavenpiler.source>11</mavenpiler.source>
<mavenpiler.target>11</mavenpiler.target>
</properties>
I have a java program that used to work and then it stopped working.
The error that I am getting is
java.sql.SQLException: No suitable driver found for jdbc:mysql://feldspar:3306/sndm
I looked into what changed, and one thing that changed was the version of mysql-connector-java
. In the last version that worked, the pom.xml
contained
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.16</version>
<optional>true</optional>
</dependency>
and in the version that did NOT work the pom.xml
contained
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.33</version>
<optional>true</optional>
</dependency>
(Note that the dependency is optional because I use maven-shade-plugin
to build different JARs for different databases.)
So I tried reverting to 8.0.16
, and it started working again.
So then I tested with different versions of the driver, and I found that with 8.0.30
it worked, but with 8.0.31
, 8.0.32
and 8.0.33
it does not work.
My code does NOT call Class.forName()
or DriverManager.registerDriver()
.
My understanding is that these methods are no longer required,
and that JDBC should find the correct driver based on the URI.
Is there a known issue with mysql-connector-java
version 8.0.33
?
p.s.
I am using Java 11
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<mavenpiler.source>11</mavenpiler.source>
<mavenpiler.target>11</mavenpiler.target>
</properties>
Share
Improve this question
edited Mar 24 at 1:29
giles3
asked Mar 24 at 0:11
giles3giles3
4872 silver badges9 bronze badges
1 Answer
Reset to default 0The official JDBC driver for MySQL is mysql-connector-j
, not mysql-connector-java
.
The latest version of mysql-connector-j
works.
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<version>9.2.0</version>
<optional>true</optional>
</dependency>
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744265160a4565831.html
评论列表(0条)