because
1.JDBC connection Mysql5 com.mysql.jdbc.Driver
:
driverClassName=com.mysql.jdbc.Driver url=jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf8&useSSL=false username=root password=root
2.JDBC connection Mysql6 com.mysql.cj.jdbc.Driver
, you need to specify the time zone serverTimezone:
driverClassName=com.mysql.cj.jdbc.Driver url=jdbc:mysql://localhost:3306/test?serverTimezone=UTC&useUnicode=true&characterEncoding=utf8&useSSL=false username=root password=root
When the set time zone, if the set serverTimezone = UTC, China would be earlier than the time 8 hours, if in China, may be selected Asia / Shanghai or Asia / Hongkong, for example:
driverClassName=com.mysql.cj.jdbc.Driver url=jdbc:mysql://localhost:3306/test?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&useSSL=false username=root password=root
I am in test time, if ShangHai will error, but using
Asia / Shanghai no problem.
The I, if mysql-connector-java with more than 6.0, as follows:
<dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>6.0.6</version> </dependency>
But your driver or use com.mysql.jdbc.Driver
, the error will be:
Loading class 'com.mysql.jdbc.Driver'. This is deprecated. The new driver class is 'com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.
At this point we need to com.mysql.jdbc.Driver
be changedcom.mysql.cj.jdbc.Driver
II, there is a warning:
WARN: Establishing SSL connection without server’s identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn’t set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to ‘false’. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
It does not recommend the use of server authentication to establish an SSL connection.
If not explicitly set, MySQL 5.5.45+, 5.6.26+ and 5.7.6+ default version requires an SSL connection.
In order to meet current application does not use SSL connection, verifyServerCertificate property is set to 'false'.
If you do not use an SSL connection, you need to set useSSL = false to disable the SSL connection explicitly.
If you need to connect with SSL, the trust will provide libraries for server certificate validation, and set useSSL = true.
SSL - Secure Sockets Layer (Secure Sockets Layer)