運行報錯:
java.sql.SQLException: The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more than one time zone…..
錯誤緣由:time zone 時區錯誤。
解決方式一
1.在鏈接MySQL的 url後面加上時區:
?serverTimezone=GMT //或者UTC 注:GMT%2B8:中國時區UTC:國際標準時區java
解決方式二
1.使用root用戶登陸mysql
2.查看時區:show variables like '%time_zone%';注:system_time_zone是值是SYSTEM(美國時間,中國要遲8小時)
3.時區設置爲當前系統時區便可,採用+8:00格式:set global time_zone='+8:00';
解決方式三
1.修改mysql的my.cnf配置文件,在[mysql]下面添加: default-time-zone=’+08:00’
注:新版本的Driver再也不使用com.mysql.jdbc.Driver,須要使用新的com.mysql.cj.jdbc.Driver