连接MYSQL数据库失败,Loading class `com.mysql.jdbc.Driver'. This is deprecated.

JDK9以后连接MYSQL数据库会报错,是因为sql语句改变了。

报错信息如下;

Loading class com.mysql.jdbc.Driver'. This is deprecated. The new driver class iscom.mysql.cj.jdbc.Driver’.

连接MYSQL数据库失败,Loading class `com.mysql.jdbc.Driver'. This is deprecated._第1张图片

解决办法;

(1)把com.mysql.jdbc.Driver 替换成com.mysql.cj.jdbc.Driver

(2)另外,给JDBC的URL指定时区。

(3)指定SSL是true或者false。

 jdbc.DriverClassName=com.mysql.cj.jdbc.Driver
    jdbc.url =jdbc:mysql://localhost:3306/student?serverTimezone=UTC&useSSL=false
    jdbc.username=root
    jdbc.password=root
    //在url中的student是指自己要用到的数据库名称,数据库不同,名称不同

According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn’t set.For compliance with existing applications not using SSL the verifyServerCertificate property is set to ‘false’. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification

报错信息说了,从MySQL 5.5.45+, 5.6.26+ and 5.7.6+ 这些个版本以后就必须指定SSL 的值true或者false。

参考网址:https://blog.csdn.net/weixin_42323802/article/details/82589743

你可能感兴趣的:(JavaWeb)