您的位置:首页 > 数据库

SQLException之serverTimeZone

2017-10-12 00:00 99 查看
使用mysql connector java连接数据库驱动

<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>6.0.6</version>
</dependency>

在升级到最新版本后需要注意的几个问题

旧的驱动类过期,提供了一个新的驱动类,替换并不影响其他操作

//旧的过期驱动
com.mysql.jdbc.Driver
//新提供的驱动类
com.mysql.cj.jdbc.Driver


ServerTimeZone配置会抛出异常

java.sql.SQLException: The server time zone value '�й���׼ʱ��' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support.

在配置url连接时需要指定时区的概念,如下:

url=jdbc:mysql://localhost/test?serverTimeZone=UTC
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  MySQL Connector/J Java
相关文章推荐