[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");


Have Questions? Post them here!
Advertisements
Try Out Code2care Dev Tools:

Advertisements

Advertisements
Code2care is an initiative to publish and share varied knowledge in programming and technical areas gathered during day-to-day learnings and development activities.

Students and software developers can leverage this portal to find solutions to their various queries without re-inventing the wheel by referring to our easy to understand posts. Technical posts might include learnings, tutorials, trouble-shooting steps, video tutorials, code snippets, how-to, blogs, articles, etc.

🎉 We are celebrating the 10th years of Code2care! Thank you for all your support!

We strongly support Gender Equality & Diversity.