“Loading class com.mysql.jdbc.Driver … is deprecated” message

It isn’t an error; it is a warning (or advisory) message resulting from a

Class.forName("com.mysql.jdbc.Driver")

call. Your code continues to run despite the message.

It is mainly telling you that the name of the driver class has changed to com.mysql.cj.jdbc.Driver. So, instead use:

Class.forName("com.mysql.cj.jdbc.Driver")

It is also letting you know that since Java 6 (JDBC 4.0) it is usually not necessary to manually load the driver class using Class.forName anyway, because JDBC is now able to load the correct driver itself (provided that the driver .jar is available on the class path).

Leave a Comment