Hello. I looked through the problems associated with this topic, but did not find the answer. Perhaps doing something wrong. The essence of the problem: I am trying to create an elementary connection to the MySQL database in Eclipse using java Actually, here is the code:

public class DB { public static void main(String[] args) { try { Class.forName("com.mysql.cj.jdbc.Driver"); System.out.println("Driver loading success!"); //у MySQL обязательно есть системная база, //к ней и будем создавать соединение. String url = "jdbc:mysql://localhost/mysql?autoReconnect=true&useSSL=false"; String name = "root"; String password = "root"; try { Connection con = DriverManager.getConnection(url, name, password); System.out.println("Connected."); con.close(); System.out.println("Disconnected."); } catch (SQLException e) { e.printStackTrace(); } } catch (ClassNotFoundException e) { e.printStackTrace(); } } } 

And in return I get:

Driver loading success!

 java.sql.SQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up. at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:108) at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:95) at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:87) at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:61) at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:71) at com.mysql.cj.jdbc.ConnectionImpl.connectWithRetries(ConnectionImpl.java:932) at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:857) at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:444) at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:230) at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:226) at java.sql.DriverManager.getConnection(Unknown Source) at java.sql.DriverManager.getConnection(Unknown Source) at telegrambot.DB.main(DB.java:41) Caused by: com.mysql.cj.exceptions.InvalidConnectionAttributeException: The server time zone value 'RTZ 2 (????)' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support. at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) at java.lang.reflect.Constructor.newInstance(Unknown Source) at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:59) at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:83) at com.mysql.cj.util.TimeUtil.getCanonicalTimezone(TimeUtil.java:128) at com.mysql.cj.protocol.a.NativeProtocol.configureTimezone(NativeProtocol.java:2201) at com.mysql.cj.protocol.a.NativeProtocol.initServerSession(NativeProtocol.java:2225) at com.mysql.cj.jdbc.ConnectionImpl.initializePropsFromServer(ConnectionImpl.java:1391) at com.mysql.cj.jdbc.ConnectionImpl.connectWithRetries(ConnectionImpl.java:895) ... 7 more 

Actually, what I have already tried to do: I tried to connect to various databases (not only standard ones) that I created myself. I downloaded various versions of JDBC Connector from 5.0 to 8.0.11 - it did not help I tried to add a new version of the driver in Eclipse, but it opposes me (I attach a screenshot) Those. He swears at the fact that he doesn’t have exactly the version of connector that he needs. Well, I think so. And when you try to connect another-gives this error

If someone tells you how to add a driver of newer versions here, I will be very grateful!

I also tried in linux to connect to an already used and working database from a Django project with exactly the correct username and password (because one of the reasons for this error could be an incorrect username and password)

Actually, everything seems to be. I killed the whole day to solve this problem and no longer know what to do. Can someone tell me?

  • Alexander, what version of MySQL, eclipse and JDK do you use? - Mikita Berazouski

1 answer 1

Everything was much simpler. When creating a new connection to the database, this error

JAR / zipin file system as specified by the driverdefinition: ...

Solved as follows:

  • 1) Go to the JAR list
  • 2) Click Clear All
  • 3) Add your driver and the eclipse no longer curses
  • 4) Set the parameters for connecting to the database and connect.

It all worked for me. Hope this helps someone too!