Reputation:
I'm getting this error while trying to establish connection with database MySQL
java.sql.SQLException: The server time zone value 'CEST' 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.
connection with MySQL is done this way:
private String CONN_STRING = "jdbc:mysql://localhost:3306/vmenginedatabaseT04P/"; // "jdbc:mysql://localhost:3306/vm_database_1";
private boolean connected ;
private Connection connection;
public boolean isConnected() {
return connected;
}
public Connection Connect() {
Connection conn = null;
try {
Class.forName("com.mysql.cj.jdbc.Driver");
conn = DriverManager.getConnection(CONN_STRING,USERNAME,PASSWORD);
System.out.println("Connected");
connected = true;
return conn;
} catch (SQLException e) {
System.err.println(e);
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
return null;
}
Upvotes: 2
Views: 1306
Reputation: 1710
Add serverTimezone=UTC
to your CONN_STRING
it will be like this :
private String CONN_STRING = "jdbc:mysql://localhost:3306/vmenginedatabaseT04P?serverTimezone=UTC"; // "jdbc:mysql://localhost:3306/vm_database_1";
Upvotes: 0
Reputation: 1454
Apparently, MySQL JDBC driver to work with CEST time zone, one has to specify the server timezone explicitly in the connection string.
jdbc:mysql://localhost/vmenginedatabaseT04P?serverTimezone=UTC
Upvotes: 1