Exception in thread “main“ java.sql.SQLException: The server time zone value ‘�й���׼ʱ��‘ is unrecogn

Posted 小田mas

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Exception in thread “main“ java.sql.SQLException: The server time zone value ‘�й���׼ʱ��‘ is unrecogn相关的知识,希望对你有一定的参考价值。

在java练习JDBC时,连接数据库发现

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.

经过冲浪,发现是系统时间错误。
需要在访问数据库的url中加上下面语句

?serverTimezone=GMT%2B8

拿我个人的例子来说
初始代码:

 String url = "jdbc:mysql://localhost:3306/mysql?useUnicode=true&characterEncoding=utf8&useSSL=true";

改正之后的代码

 String url = "jdbc:mysql://localhost:3306/mysql?useUnicode=true&characterEncoding=utf8&useSSL=true&serverTimezone=GMT%2B8";

即加上了&serverTimezone=GMT%2B8。

以上是关于Exception in thread “main“ java.sql.SQLException: The server time zone value ‘�й���׼ʱ��‘ is unrecogn的主要内容,如果未能解决你的问题,请参考以下文章

错误:Exception in thread “main“ java.lang.ClassCastException

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1

Exception in thread "main" java.lang.NullPointerException at Class.main

Exception in thread "main" java.lang.ClassCastException

Exception in thread "main" org.springframework.mail.MailSendException; nested exception de

Exception in thread “main“ java.lang.NoClassDefFoundError: org/apache/flink/