com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure

¥10.00

数据库链接失败,启动时报错:com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure。 这个问题该如何解决



最佳解决方案

原因分析

出现数据库链接失败,一般是因为网络问题造成,少数情况下也可能是配置造成的

1、网络问题


     链接端口是否开放;

     数据库所在服务器网络或者本地网络是否正常;

     是否使用了网络代理工具,例如vpn等


2、检查程序或者数据库配置是否正确

     数据库是否允许远程链接;

    spring配置是否正确

    可以在spring中做如下配置,即可解决问题:

#下面这两个配置,可以在每次连接的时候判断一些连接是否有效
spring.datasource.druid.test-on-borrow=true
spring.datasource.druid.test-while-idle=true

程序人生 T0 被采纳率100%
2021-03-24 17:37
打赏 0 1
页面统计
6351 访问
0 帮助
0.00 打赏

hierror 2019 © hierror.com 京ICP备13026190号-1

通知消息
  • 暂无任何消息