How To Fix MySQL JDBC 08001 Database Connection Error

When you use MySQL JDBC driver to connect to MySQL database server. You may encounter bellow error messages.

try {
    Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/dev2qa?useSSL=false","test","666888");
} catch (SQLException ex) {
    System.out.println("SQL State : " + ex.getSQLState());

mysql jdbc 08001 could not create connection to database server

INFO: Pre-instantiating singletons in org.s[email protected]36d64342: defining beans [org.springframework.beans.factory.config.PropertyPlaceholderConfigurer#0,dataSource,userAccountDao]; root of factory hierarchy
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server.

And the SQL State code is 08001. The reason for this error is that your MySQL JDBC jar file version do not match the MySQL database server version.

1. Get MySQL Database Server Version Number.

  1. Open System Preferences in MacOS.
  2. Click MySQL icon in the popup window.
  3. Then you can get the MySQL server version.
    start stop configure mysql server panel

2. Download Matched MySQL Server JDBC Version Jar File.

  1. You can download MySQL JDBC jar file from maven repository. If your MySQL server version is 8.0.12 so you should download JDBC jars version 8.0.12 or 8.
  2. If you use maven and pom.xml to manage your project dependency jar files, you should specify the JDBC jar file version in the pom.xml as below.
0 0 votes
Article Rating
Notify of

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Oldest Most Voted
Inline Feedbacks
View all comments

This article was really helpful. Tried tons of options before reaching out here.
Such a simple issue that costed me an entire day. Thanks for the help.


This was very helpful. Thank you

Would love your thoughts, please comment.x