MySQL 8.0.16 JDBC 数据库连接问题

Mysql 版本:mysql Ver 8.0.16 for Win64 on x86_64 (MySQL Community Server - GPL), 使用 5.x.x 或较低版本的 JDBC driver for MySQL 会出现连接问题:

1
2
3
Caused by: java.lang.ClassCastException: java.math.BigInteger cannot be cast to java.lang.Long
at com.mysql.jdbc.ConnectionImpl.buildCollationMapping(ConnectionImpl.java:1019)
... 16 more

需要修改驱动器为对应的版本

1
2
3
4
5
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.16</version>
</dependency>

InvalidConnectionAttributeException

1
2
3
Caused by: com.mysql.cj.exceptions.InvalidConnectionAttributeException: 

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 设置 serverTimezone属性

1
jdbc:mysql://localhost:3306/world?serverTimezone=UTC

MySQL Connector/J Database URL

1
2
3
4
jdbc:mysql://[host][,failoverhost...]
[:port]/[database]
[?propertyName1][=propertyValue1]
[&propertyName2][=propertyValue2]...

left join 与 left outer join 的区别

事务的隔离级别

Vector 的使用

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
@CallerSensitive
public static java.util.Enumeration<Driver> getDrivers() {
java.util.Vector<Driver> result = new java.util.Vector<>();

Class<?> callerClass = Reflection.getCallerClass();

// Walk through the loaded registeredDrivers.
for(DriverInfo aDriver : registeredDrivers) {
// If the caller does not have permission to load the driver then
// skip it.
if(isDriverAllowed(aDriver.driver, callerClass)) {
result.addElement(aDriver.driver);
} else {
println(" skipping: " + aDriver.getClass().getName());
}
}
return (result.elements());
}