which JDBC connector to user for mysql 8.0.15

Sara picture Sara · Feb 24, 2019 · Viewed 10.4k times · Source

I have installed MYSQL 8.0.15 and I have mysql-connector-java-5.1.47-bin.jar driver, but my connection would fail. I have spent almost all day, but now I have started to think: am I using the right connector? When I was looking on website, it takes me to following page. But I couldn't see any driver there.

Where can I find the right connector/driver?

Answer

Bill Karwin picture Bill Karwin · Feb 24, 2019

"MySQL Connector/J" is their product name for the JDBC driver.

Download MySQL Connector/J and extract the archive. You will find the file mysql-connector-java-8.0.15.jar in the top directory of that archive.

Java is platform-independent. I am using a Macbook, and I choose the platform-independent archive. All that means is that it's packages as a tar or zip archive, instead of an installer package for Linux or Windows. They used to offer MacOS installers, but they seem to have discontinued that.


There's an easier way to connect using the DriverManager interface. See example code here: https://dev.mysql.com/doc/connector-j/8.0/en/connector-j-usagenotes-connect-drivermanager.html#connector-j-examples-connection-drivermanager

Make sure the mysql-connector-java-8.0.15.jar is listed in your CLASSPATH. Keep in mind my rule of Java programming:

In Java, 90% of problems are due to the CLASSPATH. The other 10% are due to GC.

https://twitter.com/billkarwin/status/809491612434767872