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