JAVA学习遇到的问题

JAVA学习遇到的问题

排错历程

随时记录学习中遇到的一些问题及其解决方法。

jdbc连接数据库时区错误

报错信息:
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.
报错原因:
该错误显示是mysql设置时区与当前电脑系统时区不符,需要手动修改时区为(中国)东八区“+8:00”.
解决方法(亲测有效):

方法一:临时解决
将jdbc.properties中url后加入?serverTimezone=UTC即可解决。

方法二:永久解决
1.打开mysql的安装目录,找到my.ini配置文件打开(注意是data目录下的mysql)
JAVA学习遇到的问题
2.再mysqld标签下加入 default-time-zone=’+08:00’ 后保存,之后重启mysql服务即可。
JAVA学习遇到的问题