IDEA连接mysql数据库出现Loading class `com.mysql.jdbc.Driver’. This is deprecated.问题的相关解决方法.
使用JDBC连接MySQL时,出现以下错误:
Loading class com.mysql.jdbc.Driver’. This is deprecated. The new driver class iscom.mysql.cj.jdbc.Driver’. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.
问题所在:jdbc驱动包名引发的问题
5.x版本的驱动文件jar包对应的是:
Class.forName(“com.mysql.jdbc.Driver”);
语句来加载数据库驱动
而我使用的是8.0x版本的数据库驱动文件,对此,需要将加载数据库驱动的语句更改为:
Class.forName(“com.mysql.cj.jdbc.Driver”);