MySQL 报错(一)

报错内容
Cause: 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.

报错内容解释
原因:java.sql.SQLException:无法识别服务器时区值’�й���׼ʱ��’或表示多个时区。如果要利用时区支持,则必须配置服务器或JDBC驱动程序(通过serverTimezone配置属性)以使用更具体的时区值。

报错原因
MySQL jdbc 6.0 版本以上必须配置“serverTimezone”参数。

解决方案
数据库 url 值要配置“serverTimezone=UTC”

<property name="url" value="jdbc:mysql://localhost:3306/mybatis?serverTimezone=UTC"/>

:UTC 代表的是全球标准时间,若我们使用的时间是北京时区也就是东八区,领先 UTC 八个小时。url 的时区使用中国标准时间。也是就serverTimezone=Asia/Shanghai。

发布了17 篇原创文章 · 获赞 6 · 访问量 1226
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章