java.sql.SQLNonTransientConnectionException:Could not create connection to database server


1.启动报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.错误

2.访问时报java.sql.SQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up.

应该是在配置mysql时,没有指定mysql的版本,而采用默认的版本,默认的版本过高,本地版本低。

因为在 mysql5 中,jdbc 的驱动是 com.mysql.jdbc.Driver,而 mysql6 及以上是 com.mysql.cj.jdbc.Driver。

所以在配置依赖时要配置mysql版本号,配置数据源时的驱动。


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM