jdbc连接问题

1. 版本引发的问题
(The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more than one time zone.)
<!--MySQL的JDBC驱动包-->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version> 8.0.13</version>
</dependency>
spring:
datasource:
type: com.zaxxer.hikari.HikariDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/test?serverTimezone=Asia/Shanghai&zeroDateTimeBehavior=convertToNull&characterEncoding=utf8&useSSL=false

username: root
password: xxxx

当mysql的JDBC驱动包版本是6(+)时,驱动名称是 com.mysql.cj.jdbc.Driver,并且必须指定serverTimezone,否则项目启动时会报serverTimezone乱码

当mysql的JDBC驱动包版本是6(-),驱动名称是com.mysql.jdbc.Driver,serverTimezone是非必需的指定
posted @ 2019-01-23 16:24  vwater  阅读(347)  评论(0编辑  收藏  举报