JDBC連接數據庫報錯:java.sql.SQLException: The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more than one time zone. ......


問題:Java程序使用JDBC連接MySQL數據庫時,控制台報錯如下:

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

 

延伸:1 GMT%2B8,即GMT+8,表示東八區。

2 %2B表示“+”,這是因為在URL地址中,只能包含特定的原始字符,其他字符,包括中文等會被編碼,但是編碼的只是URL地址,如果地址后面還有參數,例如

則,wd屬於查詢字符串,不屬於網址路徑。所以可以不用被編碼。

 

參考:https://blog.csdn.net/github_35186068/article/details/80919528

https://blog.csdn.net/chenlycly/article/details/51820727

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM