Summary of Mysql-connector-java driver version issues

Summary of Mysql-connector-java driver version issues

Mysql-connector-java driver version problem

Since my database version is 5.7.28, version problems often occur when using java to connect to mysql.

  • com.mysql.jdbc.Driver is in mysql-connector-java 5,
  • com.mysql.cj.jdbc.Driver is in mysql-connector-java 6

Establishing an SSL connection without server authentication is not recommended.
MySQL 5.5.45+, 5.6.26+ and 5.7.6+ versions require SSL connections by default if not set explicitly.
To comply with applications that do not currently use SSL connections, the verifyServerCertificate property is set to 'false'.
If you do not need to use SSL connections, you need to explicitly disable SSL connections by setting useSSL=false.
If you need to connect using SSL, provide a truststore for server certificate verification and set useSSL=true.

SSL – Secure Sockets Layer

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.

Cause of error:
The driver url used by MySQL5 is com.mysql.jdbc.Driver, and MySQL6 and later use com.mysql.cj.jdbc.Driver. If the versions do not match, an error indicating that the driver class is outdated will be reported.
Solution:
Changing the driver class name in the configuration file can eliminate the warning that the driver class is out of date.

Even if the driver name is changed to com.mysql.cj.jdbc.Driver in mysql5.7.28, an error will still be reported. The reason is that the version in the pom project object model file is not changed to

mysql-connector-java8.0 or later

mysql-connector-java and MySQL corresponding versions

Since my version is mysql5.7.28 using connector-java version 5.1, the above error still occurs. Therefore, use connector-java 8.0 or above in mysql5.6 or above.

And you need to set the time zone when using it

driverClassName=com.mysql.cj.jdbc.Driver
url=jdbc:mysql://localhost:3306/database name?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&useSSL=false
username=root
password=

The serverTimezone here must be written as serverTimezone=Asia/Shanghai. Writing it as serverTimezone=Shanghai will also result in an error. It seems that the time zone of Shanghai cannot be found. There may be more than one Shanghai in the world, haha!

mysql-connector-java and Java corresponding version

In view of the above, for beginners, it is better to use mysql-connector-java 8.0 or above

The above is the details of the Mysql-connector-java driver version problem. For more information about the Mysql connector java driver, please pay attention to other related articles on 123WORDPRESS.COM!

You may also be interested in:
  • Detailed explanation of the download process of the mysql-connector-java.jar package
  • Notes on upgrading to mysql-connector-java8.0.27

<<:  Three.js realizes Facebook Metaverse 3D dynamic logo effect

>>:  Unicode signature BOM (Byte Order Mark) issue for UTF-8 files

Recommend

Detailed explanation of keywords and reserved words in MySQL 5.7

Preface The keywords of MySQL and Oracle are not ...

How to successfully retrieve VMware Esxi root password after forgetting it

Prepare a CentOS6 installation disk (any version)...

Tutorial on installing mysql5.7.18 on mac os10.12

I searched the entire web and found all kinds of ...

Sample code using scss in uni-app

Pitfalls encountered I spent the whole afternoon ...

Complete the search function in the html page

Recently I've been working on a framework tha...

How to configure MySQL master-slave replication under Windows

MySQL master-slave replication allows data from o...

How to implement on-demand import and global import in element-plus

Table of contents Import on demand: Global Import...

Solve the installation problem of mysql8.0.19 winx64 version

MySQL is an open source, small relational databas...

More Ways to Use Angle Brackets in Bash

Preface In this article, we will continue to expl...

17 JavaScript One-Liners

Table of contents 1. DOM & BOM related 1. Che...

How to install Apache service in Linux operating system

Download link: Operating Environment CentOS 7.6 i...

mysql solves time zone related problems

Preface: When using MySQL, you may encounter time...

Using JS to implement binary tree traversal algorithm example code

Table of contents Preface 1. Binary Tree 1.1. Tra...

How to recover data after accidentally deleting ibdata files in mysql5.7.33

Table of contents 1. Scenario description: 2. Cas...