The new driver class is com.mysql.cj.jdbc.Driver deprecated

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.

 

com.mysql.jdbc.Driver, the MySQL driver deprecated, you can use new MySQL driver i.e com.mysql.cj.jdbc.Driver

 

com.mysql.cj.jdbc.Driver is the new drive class you can use old driver com.mysql.jdbc.Driver nothing problem it will work but in the console/log warning message will be displayed.

The warning mess is

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.

 

Sample Database connection for New Driver – com.mysql.cj.jdbc.Driver

 

Nothing much changes, you just replace the old driver class with new driver class.

Old MySQL Driver Example

Class.forName("com.mysql.jdbc.Driver");
Connection con=DriverManager.getConnection("jdbc:mysql://localhost/identityiq?useServerPrepStmts=true&tinyInt1isBit=true&useUnicode=true&characterEncoding=utf8&serverTimezone=UTC","root","Admin1234"); 

 

New MySQL Driver Example

Class.forName("com.mysql.cj.jdbc.Driver");
Connection con=DriverManager.getConnection("jdbc:mysql://localhost/identityiq?useServerPrepStmts=true&tinyInt1isBit=true&useUnicode=true&characterEncoding=utf8&serverTimezone=UTC","root","Admin1234");

 

 

 

Leave a Reply