- 使用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
时间: 2024-10-11 21:09:57