java.sql.SQLException: 服务器时区值 – 使用端口和名称进行连接

huangapple 未分类评论45阅读模式
英文:

java.sql.SQLException: The server time zone value - connecting using port and name

问题

我正在填写我的应用程序中的一些文本字段,并希望将它们发送到数据库"appforhh"。但是我收到了以下错误:

> java.sql.SQLException: 服务器时区值'RTZ 2 (����)'无法识别或表示多个时区。如果要使用时区支持,您必须配置服务器或JDBC驱动程序(通过'serverTimezone'配置属性)以使用更具体的时区值。

我尝试在MySQL中执行 SET GLOBAL time_zone = '+3:00';,但没有任何变化。

public class DataBaseHandler extends Configs {
    Connection dbConnetion;

    public Connection getDbConnetion() throws ClassNotFoundException, SQLException {
        String connectionString = "jdbc:mysql://" //连接字符串
                + dbHost + ":"
                + dbPort + "/"
                + dbName;
        Class.forName("com.mysql.cj.jdbc.Driver");
        dbConnetion = DriverManager.getConnection(connectionString, dbUser, dbPass);
        return dbConnetion;
    }
}
英文:

I'm filling in some text fields in my app and want to send them to the database "appforhh". But I get the error:

> java.sql.SQLException: The server time zone value 'RTZ 2 (����)' 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.

I tried SET GLOBAL time_zone = '+3:00'; in mySQL, but nothing changed.

public class DataBaseHandler extends Configs {
Connection dbConnetion;

public Connection getDbConnetion() throws ClassNotFoundException, SQLException {
    String connectionString = "jdbc:mysql://" //Connection String
            + dbHost + ":"
            + dbPort + "/"
            + dbName;
    Class.forName("com.mysql.cj.jdbc.Driver");
    dbConnetion = DriverManager.getConnection(connectionString, dbUser, dbPass);
    return dbConnetion;
}

huangapple
  • 本文由 发表于 2020年4月7日 01:27:11
  • 转载请务必保留本文链接:https://java.coder-hub.com/61065450.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定