JDBC 连接错误:无法识别时区 [英] JDBC connection error : unrecognized timezone

查看:29
本文介绍了JDBC 连接错误:无法识别时区的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

这是我的连接代码.

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

}

推荐答案

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

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?

这篇关于JDBC 连接错误:无法识别时区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆