Connector/J error after upgrade mysql to version 8

3.5k views Asked by At

Problem:

I upgraded mysql to newest version:

127.0.0.1$ mysql -V 
mysql  Ver 14.14 Distrib 8.0.0-dmr, for Linux (x86_64) using  EditLine wrapper

Now I cannot connect with mysql by jdbc using driver connector/j in program mathematica. When I am trying do this, then I see exception:

JDBC::error: java.lang.ClassCastException: java.math.BigInteger cannot be cast to java.lang.Long

Debugging that I done

In purpose to debug I installed oldest mysql on virtual machine.

192.168.43.48$ mysql -V
mysql Ver 14.14 Distrib 5.5.53, for debian-linux-gnu (x86_64) using readline 6.3

And connection with oldest mysql was done correctly.

You can see commands initializing connections and these results on the screen:

error.png

My Mathematica uses the following version of JDBC and Connector/J:

  • JDBC has version 3
  • Connector/J has 5.1.27

I am obtaining these info by execution command (in mathematica not bash):

JDBCDrivers["MySQL(Connector/J)"]

that gives output:

JDBCDriver["Name" -> "MySQL(Connector/J)", 
"Driver" -> "com.mysql.jdbc.Driver", "Protocol" -> "jdbc:mysql://", 
 "Version" -> 3., 
 "Description" -> 
  "MySQL using Connector/J - Version 5.1.27 - This supports all known \
MySQL server versions.", 
 "Location" -> 
  "/usr/local/Wolfram/Mathematica/10.0/SystemFiles/Links/DatabaseLink/\
DatabaseResources/mysql.m"]

I append info about java version:

127.0.0.1$ java -version
openjdk version "9-internal"
OpenJDK Runtime Environment (build 9-internal+0-2016-04-14-195246.buildd.src)
OpenJDK 64-Bit Server VM (build 9-internal+0-2016-04-14-195246.buildd.src, mixed mode)

Should I upgrade jdbc, connector/j, or downgrade mysql? Maybe is there another solution?

1

There are 1 answers

0
Steven Buehler On BEST ANSWER

Connector/J 5.x will not connect to a MySQL 8.x database; you have to use the 8.0.x Connector/J driver.

Note that with the 8.0.x Connector/J driver the classpath also changed, from com.mysql.jdbc.Driver to com.mysql.cj.jdbc.Driver.