Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JDBC connection error : unrecognized timezone [duplicate]

Tags:

java

mysql

jdbc

I getting this error when connect to mysql database with JDBC.

Database.getConnection() Error -->The server time zone value 'EEST' 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.

That is my connection code.

public static Connection getConnection(){
    try {
        Class.forName("com.mysql.jdbc.Driver");

        Connection con = DriverManager.getConnection(
                "jdbc:mysql://localhost:3306/management", "root", "root");
        return con;
    } catch (ClassNotFoundException | SQLException e) {
        // TODO Auto-generated catch block
        System.out.println("Database.getConnection() Error -->"
                + e.getMessage());
        return null;
    }

}
like image 988
mcemilg Avatar asked Apr 27 '16 12:04

mcemilg


People also ask

How do I set timezone in JDBC?

To set the timezone for a given JDBC connection, navigate to the Advanced tab and select the timezone from the dropdown menu. By default, UTC is selected.

How do I change timezone to UTC in MySQL?

Option 2: Edit the MySQL Configuration File Scroll down to the [mysqld] section, and find the default-time-zone = "+00:00" line. Change the +00:00 value to the GMT value for the time zone you want. Save the file and exit. In the example below we set the MySQL Server time zone to +08:00 (GMT +8).

How do I set MySQL server time zone?

To explicitly specify the system time zone for MySQL Server at startup, set the TZ environment variable before you start mysqld. If you start the server using mysqld_safe, its --timezone option provides another way to set the system time zone. The permissible values for TZ and --timezone are system dependent.

What is JDBC and what is its purpose?

Java™ database connectivity (JDBC) is the JavaSoft specification of a standard application programming interface (API) that allows Java programs to access database management systems. The JDBC API consists of a set of interfaces and classes written in the Java programming language.


1 Answers

I think there is an issue with the mismatch timezone with Mysql and system. So its better to set the value to be in sync. You can also refer the below link to set the time: How do I set the time zone of MySQL?

like image 110
Panky031 Avatar answered Oct 13 '22 00:10

Panky031