java匯入mysql jar包,註冊驅動時發生錯誤:
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
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)
一執行就發生該錯誤。
後來發現這個是系統時間錯誤。
只需要在訪問資料庫的Url後面加上以下的語句即可:
?serverTimezone=GMT%2B8
例如URL為:
jdbc:mysql://localhost:port/my_test
修改為:
jdbc:mysql://localhost:port/my_test?serverTimezone=GMT%2B8
問題就迎刃而解啦。
新的開始
這是我的第一個部落格,我也是一個程式設計小白,還在漫長學習之中…
以後會將程式設計中遇到的困難發到部落格上,記錄下來。
希望大家一起學習交流吧!
本文章已修改原文用詞符合繁體字使用者習慣使其容易閱讀
版權宣告:此處為CSDN博主「゛Cryin、」的原創文章,依據CC 4.0 BY-SA版權協議,轉載請附上原文出處連結及本宣告。
原文連結:https://blog.csdn.net/qq_43460693/article/details/101280394