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