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

 



  • 2018-03-13 22:42:44

    TraceView报错:unable to open trace file

    程序效率有些问题,想起用TraceView来分析一下,可是一直报标题中的错误,无法创建出我所需要的aa.trace文件,分析也就无从做起。

  • 2018-03-14 17:41:44

    MySQL的if,case语句使用总结

    Mysql的if既可以作为表达式用,也可在存储过程中作为流程控制语句使用,如下是做为表达式使用:

  • 2018-03-16 23:56:14

    layer-list -- layer-list的基本使用介绍

    简单理解,layer 是层,list 是列表,那么 layer-list 就是层列表的意思。但是,是什么层列表呢?? 其实 layer-list 是用来创建 LayerDrawable 的,LayerDrawable 是 DrawableResource 的一种, 所以,layer-list 创建出来的是 图层列表,也就是一个drawable 图形。