zoukankan      html  css  js  c++  java
  • java.sql.SQLException: The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized

    Exception in thread "main" java.sql.SQLException: The server time zone value 'Öйú±ê׼ʱ¼ä' 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.
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:127)
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:95)
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:87)
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:61)
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:71)
    at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:76)
    at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:862)
    at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:444)
    at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:230)
    at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:226)
    at java.sql.DriverManager.getConnection(DriverManager.java:664)
    at java.sql.DriverManager.getConnection(DriverManager.java:247)

    这是在使用MySQL 8.0以上版本(MySQL连接驱动和版本都是8.0以上)的时候出现的问题错误,我们需要在访问数据库的Url后面加上

    ?serverTimezone=GMT%2B8

    比如我的URL配置是  jdbc_url=jdbc:mysql://localhost:3306/test

    修改成:jdbc_url=jdbc:mysql://localhost:3306/test?serverTimezone=GMT%2B8

    如果读取数据库的数据乱码了,需要增加UTF-8,修改如下:

    jdbc:mysql://localhost:3306/test?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf-8

  • 相关阅读:
    LINQ篇:ASP.NET using LINQ(Part One) Scott大师的产物
    运算符重载 operator+[纯属温习啊][附加了一些内容 如:同名属性,复制构造函数]
    Vista中低端电脑如何打开Aero效果或者就是3D效果
    基于可配置化的设计[原创][4.20更新]
    Treeview控件如何在asp.net ajax中使用小技巧
    PetShop 4.0 系列之四 [转]
    XML篇查询语言XPath
    抽象工厂模式[转]
    何时使用委托而不使用接口
    DNN开篇第一话
  • 原文地址:https://www.cnblogs.com/zhangliang88/p/10315315.html
Copyright © 2011-2022 走看看