[fix] Loading class com.mysql.jdbc.Driver is deprecated


Java MySQL Warning:
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.

If you are working on a JDBC project with Java and MySQL and you get the above warning message in your console is because the DriverManager connection string that you are using to register MySQL has changed and you should be using com.mysql.cj.jdbc.Driver instead of com.mysql.jdbc.Driver

MySQL Driver depricated Warning Java
Solution:

Replace,

com.mysql.jdbc.Driver

with,

com.mysql.cj.jdbc.Driver

Example:
Class.forName("com.mysql.jdbc.Driver");

Facing issues? Have Questions? Post them here! I am happy to answer!

Author Info:

Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.

Follow him on: X

You can also reach out to him via e-mail: rakesh@code2care.org

Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap