Java JDBC 连接错误:无法识别时区

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/36890422/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 18:45:52  来源:igfitidea点击:

JDBC connection error : unrecognized timezone

javamysqljdbc

提问by mcemilg

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

使用 JDBC 连接到 mysql 数据库时出现此错误。

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;
    }

}

采纳答案by Panky031

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?

我认为 Mysql 和系统的时区不匹配存在问题。所以最好将值设置为同步。您也可以参考以下链接来设置时间:如何设置 MySQL 的时区?