某次连接Mysql数据库时候出现了报错
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小时。解决方法也很简单
解决方法
在db连接串后面加上:?serverTimezone=UTC,完整示例:jdbc:mysql://localhost:3306/dbname?serverTimezone=UTC【可以指定时区问题】
补充
在db连接串后面加上:?useUnicode=true&characterEncoding=UTF-8,完整示例:jdbc:mysql://localhost:3306/dbname?useUnicode=true&characterEncoding=UTF-8 【可以解决中文乱码问题】
当然也可以联合起来用jdbc:mysql://localhost:3306/dbname?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC
网上还有一种办法就是修改mysql安装路径下的my.ini文件
在[mysqld]下方添加:default-time-zone=’+08:00’。(注意引号)