运行报错:
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