Reputation: 569
This error has already been dealt with several times in the forum, but I meet the error for the first time after updating to MySQL 8.0 and the solutions proposed for previous versions didn't work. I found, however, two ways to prevent the error:
Having done so, the error will not happen any more until I restart the PC. Launching "Computer Management" (Win10) and looking at the services, I see "MySQL80" with a status of "Running" right after PC startup. So that seems to be ok.
I am using MySQL Server version: 8.0.12 and mysql-connector-java 8.0.12.
Here's the java code I use to get a connection. With 8.0 I had to add time zone information to make it work. See what other flags I tested as well.
import java.sql.*;
import java.util.*;
public class Test {
String url= "jdbc:mysql://localhost/myDb?autoReconnect=true&useSSL=false";
public Test() {
try {
Connection conn= DriverManager.getConnection(url+"&serverTimezone=CET",
// "&useJDBCCompliantTimezoneShift=true"+
// "&useUnicode=true&characterEncoding=UTF-8"+
// "&zeroDateTimeBehavior=CONVERT_TO_NULL",
"root",
"mypass");
System.out.println(conn);
}
catch(SQLException e) {
System.out.println(e);
}
System.exit(0);
}
public static void main(String args[]) {
EventQueue.invokeLater(Test::new);
}
}
Edit: Just updated to server and J/Connector 8.0.13, but the java.sql.SQLNonTransientConnectionException persists.
Upvotes: 0
Views: 3562
Reputation: 569
In my given test case one has to remove "&useSSL=false".
In Connector/J 8.0 "useSSL" has been replaced by "sslMode" and "useSSL" has, indeed, been deprecated. But to me "deprecated" doesn't mean "illegal". So now we know: Beware of deprecation!
At least at my location (central Europe) specifying serverTimezone seems to be a must (Runtime error).
Upvotes: 1