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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章