The server time zone value ‘???ú±ê×??±??’ is unrecognized or represents more than one time zone-错误

错误描述

MySQL5.7使用高版本的连接桥后出现时区乱码的情况,然而红色字体的翻译大意:服务器的时区值”? ? ?你±e×? ?±? ?(乱码)“无法识别或代表多个时区。您必须配置服务器或JDBC驱动程序(通过serverTimezone配置属性)使用一个更具体的时区值如果你想利用时区支持。

org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (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 org.apache.commons.dbcp.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:1549)
at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1388)
   at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044)
   at org.apache.commons.dbutils.AbstractQueryRunner.prepareConnection(AbstractQueryRunner.java:204)
   at org.apache.commons.dbutils.QueryRunner.update(QueryRunner.java:455)
   at nubi.datasource.dbcp.Test.insert(Test.java:18)
   at nubi.datasource.dbcp.Test.main(Test.java:10)
Caused by: 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.

解决方案

在url中”jdbc:mysql://localhost:3306/mydatabase?useUnicode=true&characterEncoding=utf-8&useSSL=true”
加上&serverTimezone=GMT%2B8,注意:GMT%2B8这是GMT+8时区

Add a Comment

邮箱地址不会被公开。