JDBC链接Mysql失败
错误信息:Error querying database. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server.
问题原因:新版本mysql数据库(我是的时8.0.15, 具体mysql那个版本未知)更改了登录用户名和密码的加密方式,老版本mysql 无法链接
解决方式:需要更新 mysql-connector-java 版本
<dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>8.0.15</version> </dependency>
更新JDBC代码后再次重连,继续报错
错误信息: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.
问题原因: mysql 驱动 package 变动
解决方法: 修改JDBC 驱动为:com.mysql.cj.jdbc.Driver
原创文章,作者:奋斗,如若转载,请注明出处:https://blog.ytso.com/notes/174334.html