错误提示:
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.
二、错误原因:时区问题,中国时区与世界时区的差异导致
1.Mysql connector的jar包版本导致,新版jar包6.0以上就会出现此错误。
2.编译器的问题,由于编译器的不同,编译结果也不太一样,有些编译器即使是5版本的Mysql connector的jar包也会出现这类问题
三、解决方法
1.更换低版本的jar包(不推荐)
2.设置时区问题
①数据库中加入命令(注意分号):
set global time_zone=’+8:00’;
非常不推荐此方法,此方法每次打关闭发开数据
库都需要重新设定时间
②在java代码中设置
DriverManager.getConnection(“jdbc:mysql://localhost:3306/数据库名称”, “root”, “root”); 改为 DriverManager.getConnection(“jdbc:mysql://loca