【原文鏈接】MySQL----JDBC無法連接數(shù)據(jù)庫,報The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server的解決辦法
問題:
1、JDBC連接數(shù)據(jù)庫時卡在如下位置
hikari.HikariDataSource |- HikariPool-1 - Starting...
2、過一會JDBC連接超時,報如下錯誤
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
3、但是手動可以連接數(shù)據(jù)庫,本地調試JAVA代碼也是可以連接數(shù)據(jù)庫,使用k8s部署后就會出現(xiàn)此問題
解決辦法
(1)在JDBC的連接的URL后面加上如下內(nèi)容
&useSSL=false&autoReconnect=true&failOverReadOnly=false&maxReconnects=10
(2)然后在pom.xml文件中增加配置如下內(nèi)容文章來源:http://www.zghlxwxcb.cn/news/detail-532979.html
<build>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
</build>
(3)重新部署后,解決文章來源地址http://www.zghlxwxcb.cn/news/detail-532979.html
到了這里,關于MySQL----JDBC無法連接數(shù)據(jù)庫,報The driver has not received any packets from the server的解決辦法的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網(wǎng)!