SQLException之serverTimeZone

来源:互联网 发布:java web 攻击 2 编辑:程序博客网 时间:2024/05/16 05:17
  • 使用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
阅读全文
0 0
原创粉丝点击