SQLException: The server time zone value '?й???????' is unrecognized 解决办法

Posted 待到花开

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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:129)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:89)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:63)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:73)
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:76)
at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:836)
at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:456)
at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:246)
at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:197)
at com.mysql.cj.jdbc.MysqlDataSource.getConnection(MysqlDataSource.java:416)
at com.mysql.cj.jdbc.MysqlDataSource.getConnection(MysqlDataSource.java:128)
at com.mysql.cj.jdbc.MysqlDataSource.getConnection(MysqlDataSource.java:113)
at test.jar_test.main(jar_test.java:51)

解决办法:连接数据库时:

((MysqlDataSource) dataSource).setURL("jdbc:mysql://127.0.0.1:3306/mysql1?characterEncoding=utf-8&useSSL=true");
修改为:
((MysqlDataSource) dataSource).setURL("jdbc:mysql://127.0.0.1:3306/mysql1?serverTimezone=UTC&useSSL=true");

以上是关于SQLException: The server time zone value '?й???????' is unrecognized 解决办法的主要内容,如果未能解决你的问题,请参考以下文章

SQLException: The server time zone value '?й???????' is unrecognized 解决办法

报错处理:Cause: java.sql.SQLException: The server time zone value

java.sql.SQLException: The server time zone value 'Öйú±ê×

异常:java.sql.SQLException: The server time zone value '?й???????' is unrecognized or represen

Exception in thread “main” java.sql.SQLException: The server time zone value ‘?й???????’ is unrecogn

java.sql.SQLException: The server time zone value ‘?й???????’ is unrecognized or represents more tha