首页
学习
活动
专区
圈层
工具
发布
社区首页 >专栏 >com.mysql.cj.exceptions.InvalidConnectionAttributeException: The server time zone value 'Öйú±ê׼ʱ¼

com.mysql.cj.exceptions.InvalidConnectionAttributeException: The server time zone value 'Öйú±ê׼ʱ¼

作者头像
johnhuster的分享
发布于 2022-03-28 20:09:55
发布于 2022-03-28 20:09:55
5850
举报
文章被收录于专栏:johnhusterjohnhuster

报了这个错说明以下几个问题:

1.你是用的mysql连接器mysql-connector-java版本在6以上

2.你的数据库time_zone没有值,通过show VARIABLES like '%time_zone%'可以查看到

3.在mysql连接属性里面没有配置serverTimezone

解决方法,在连接属性上加上serverTimezone属性即可

代码语言:javascript
复制
    driver-class-name: com.mysql.cj.jdbc.Driver
     type: com.alibaba.druid.pool.DruidDataSource
     url: jdbc:mysql://xxxxxx?useUnicode=true&charactorEncoding=utf-8&autoReconnect=true&allowMultiQueries=true&zeroDateTimeBehavior=convertToNull&serverTimezone=Asia/Shanghai

现在mysql官网推荐使用新版的com.mysql.cj.jdbc.Driver,com.mysql.jdbc.Driver已不再维护!

更多mysql连接属性请参考mysql官网:https://dev.mysql.com/doc/connector-j/8.0/en/connector-j-reference-configuration-properties.html

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2019/09/24 ,如有侵权请联系 cloudcommunity@tencent.com 删除
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档