The differences between com. mysql. jdbc. Driver and com. mysql. cj. jdbc. Driver,
Overview: com. mysql. jdbc. Driver is in mysql-connector-java 5, while com. mysql. cj. jdbc. Driver is in mysql-connector-java 6.
1. JDBC to connect to Mysql5 requires com. mysql. jdbc. Driver, for example:
DriverClassName = com. mysql. jdbc. Driver
Url = jdbc: mysql: // localhost: 3306/test? UseUnicode = true & characterEncoding = utf8 & useSSL = false
Username = root
Password = root
2. To connect JDBC to Mysql6, you must use com. mysql. cj. jdbc. Driver and specify the time zone serverTimezone. For example:
DriverClassName = com. mysql. cj. jdbc. Driver
Url = jdbc: mysql: // localhost: 3306/test? ServerTimezone = UTC &? UseUnicode = true & characterEncoding = utf8 & useSSL = false
Username = root
Password = root
3. When you set the time zone, serverTimezone = UTC is eight hours earlier than the China time. If you are in China, set serverTimezone = Shanghai or serverTimezone = Hongkong. For example:
DriverClassName = com. mysql. cj. jdbc. Driver
Url = jdbc: mysql: // localhost: 3306/test? ServerTimezone = Shanghai &? UseUnicode = true & characterEncoding = utf8 & useSSL = false
Username = root
Password = root
4. If mysql-connector-java uses more than 6.0, for example:
<Dependency>
<GroupId> mysql </groupId>
<ArtifactId> mysql-connector-java </artifactId>
<Version> 6.0.6 </version>
</Dependency>
However, if your driver still uses com. mysql. jdbc. Driver, an error will be reported. In this case, you need to change com. mysql. jdbc. Driver to com. mysql. cj. jdbc. Driver.