【问题标题】:JDBC connection error : unrecognized timezone [duplicate]JDBC连接错误:无法识别的时区[重复]
【发布时间】:2016-08-21 18:52:40
【问题描述】:

使用 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.

这是我的连接代码。

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

}

【问题讨论】:

  • 错误信息已经够清楚了。 确切地说你不明白什么?
  • SO,您是否尝试过更正服务器时区?
  • 我没有找到 serverTimezone 配置属性。

标签: java mysql jdbc


【解决方案1】:

我认为 Mysql 和系统的时区不匹配存在问题。 所以最好将值设置为同步。 您也可以参考以下链接设置时间:How do I set the time zone of MySQL?

【讨论】:

    猜你喜欢
    • 2021-03-04
    • 2016-09-10
    • 1970-01-01
    • 2014-05-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-12
    相关资源
    最近更新 更多