码上敲享录 > mysql实战经验分享 > Caused by: java.sql.SQLException: The server time zone value...,You must configure either the server

Caused by: java.sql.SQLException: The server time zone value...,You must configure either the server

章节目录下一章 2018-01-07已有2623人阅读 评论(0)

有时候备份一份数据库到别的服务器或本地上的数据库,在web项目的数据库连接配置文件中修改成新的属性后,启动tomcat报错:

Caused by: java.sql.SQLException: The server time zone value...,You must configure either the server or JDBC driver


原因分析:

在使用mysql的jdbc驱动最新版(6.0+)时(如果使用这个高版本的驱动com.mysql.cj.jdbc.Driver就会出现这个问题;如果使用这个驱动com.mysql.jdbc.Driver连接时就不会出现错误),遇到数据库和系统时区差异引起的问题。


解决方法:

最有效的方法就是在jdbc连接的url后面加上serverTimezone=UTC(推荐这个)或GMT即可。

spring.datasource.url=jdbc:mysql://localhost:3306/labour?serverTimezone=UTC&useSSL=true&verifyServerCertificate=false&Unicode=true&characterEncoding=UTF8




本文地址:http://www.yayihouse.com/yayishuwu/chapter/1075

向大家推荐《Activiti工作流实战教程》:https://xiaozhuanlan.com/activiti
1

有建议,请留言!

  • *您的姓名:

  • *所在城市:

  • *您的联系电话:

    *您的QQ:

  • 咨询问题:

  • 提 交