【原文链接】MySQL----JDBC无法连接数据库,报The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server的解决办法
问题:
1、JDBC连接数据库时卡在如下位置
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、但是手动可以连接数据库,本地调试JAVA代码也是可以连接数据库,使用k8s部署后就会出现此问题
解决办法
(1)在JDBC的连接的URL后面加上如下内容
&useSSL=false&autoReconnect=true&failOverReadOnly=false&maxReconnects=10
(2)然后在pom.xml文件中增加配置如下内容文章来源:https://www.toymoban.com/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)重新部署后,解决文章来源地址https://www.toymoban.com/news/detail-532979.html
到了这里,关于MySQL----JDBC无法连接数据库,报The driver has not received any packets from the server的解决办法的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!