You must configure either the server or JDBC driver (via the serverTimezone configuration property)

2020-06-24 10:16:41

参考连接 You must configure either the server or JDBC driver (via the serverTimezone configuration property)

JDBC使用8.0驱动包连接mysql设置时区serverTimezone

驱动包用的是新版 mysql-connector-java-8.0.16.jar
新版的驱动类改成了com.mysql.cj.jdbc.Driver
新版驱动连接url也有所改动
I、指定时区

如果不设置时区会相差13个小时
比如在java代码里面插入的时间为:2019-07-26 19:28:02
但是在数据库里面显示的时间却为:2019-07-26 06:28:02

所以使用上海时间(注意:没有asia/beijing时区)
serverTimezone=Asia/Shanghai

II、指定是否用ssl连接,true值还报错了
useSSL=false

完整代码:

url=jdbc:mysql://ip:port/xxx?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&serverTimezone=Asia/Shanghai&useSSL=false
driverClassName=com.mysql.cj.jdbc.Driver

 



  • 2021-03-02 16:00:30

    git pull时的filename too long的错误

    这是因为git在windowa下的文件名长度最大是260,(git在Linux下最大支持4096长度的文件名),可以通过输入以下命令解决:

  • 2021-03-05 13:18:03

    mjml教程详解

    mjml如何快速编写响应式电子邮件

  • 2021-03-15 10:34:55

    Sass函数:Sass Maps的函数-map-get($map,$key)

    map-get($map,$key) 函数的作用是根据 $key 参数,返回 $key 在 $map 中对应的 value 值。如果 $key 不存在 $map中,将返回 null 值。此函数包括两个参数: