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

How to create a file system in a Linux partition or logical volume

Preface Learn to create a file system on your sys...

SQL serial number acquisition code example

This article mainly introduces the sql serial num...

The Complete Guide to Grid Layout in CSS

Grid is a two-dimensional grid layout system. Wit...

Beginners learn some HTML tags (1)

Beginners can learn HTML by understanding some HT...

Detailed deployment of docker+gitlab+gitlab-runner

environment Server: centos7 Client: window Deploy...

mysql 5.7.11 winx64.zip installation and configuration method graphic tutorial

Install and configure the MySql database system. ...

Detailed explanation of the basic use of centos7 firewall in linux

1. Basic use of firewalld start up: systemctl sta...

Detailed explanation of Linux copy and paste in VMware virtual machine

1. Linux under VMware Workstation: 1. Update sour...

How to transfer files between Docker container and local machine

To transfer files between the host and the contai...

Explain the difference between iframe and frame in HTML with examples

I don't know if you have used the frameset at...

Four ways to switch tab pages in VUE

Table of contents 1. Static implementation method...

Use of Linux cal command

1. Command Introduction The cal (calendar) comman...