数据库连接失败

一、例如我在SpringBoot项目中使用了阿里的数据库连接池Driud。

有次在启动的时候,会报这样的错:

Caused by: com.mysql.cj.exceptions.CJCommunicationsException: Communications link failure

The last packet successfully received from the server was 319 milliseconds ago.  The last packet sent successfully to the server was 319 milliseconds ago.

就是数据库连接失败的问题。

二、定位问题

为什么会出现这样的一个问题呢?

出现这样的一个问题,首先确定是不是数据库问题,看看数据库能不能连上。

如果你的同事或者其他人都能够连上,那么数据库就没有问题。

看看你能不能上网。

如果你能上网,你的网络还OK。

三、代理问题

如果你使用了代理,就是哪种能帮助你上谷歌的软件。

你将它关掉,看看问题是否解决了。

四、增加一个配置

下面这两个配置,可以在每次连接的时候判断一些连接是否有效

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

解决:com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure(真实有效)的更多相关文章

  1. 【Azure 应用服务】App Service 无法连接到Azure MySQL服务,报错:com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure

    问题描述 App Service使用jdbc连接MySQL服务,出现大量的  Communications link failure: com.mysql.cj.jdbc.exceptions.Com ...

  2. Java连接数据库报错:com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure

    解决方案 连接Mysql报错 The last packet sent successfully to the server was 0 milliseconds ago. The driver ha ...

  3. Java连接MySQL报错:CommunicationsException: Communications link failure

    现象: 报错:Exception in thread "main" com.mysql.cj.jdbc.exceptions.CommunicationsException: Co ...

  4. com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure 解决办法

    09:00:30.307 [http-8080-6] ERROR org.hibernate.transaction.JDBCTransaction -JDBC begin failed com.my ...

  5. 异常解决:Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

    异常描述 这个异常通常有如下信息: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failu ...

  6. mysql 5.1超过默认8小时空闲时间解决办法(错误:com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure)

    报错: MySQL第二天早上第一次连接超时报错, com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications lin ...

  7. Cause: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure 解决

    感谢大佬:https://blog.csdn.net/a704397849/article/details/93797529 springboot + mybatis多数据库 + druid连接池配置 ...

  8. com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure 数据库报错

    -- 查询mysql 数据库链接空闲时间持有最大空闲时间,单位为秒 SHOW VARIABLES WHERE VAriable_name = 'interactive_timeout'; -- 会出现 ...

  9. Oozie时出现Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure?

    不多说,直接上干货! 问题详情 [hadoop@bigdatamaster oozie--cdh5.5.4]$ bin/ooziedb.sh create -sqlfile oozie.sql -ru ...

随机推荐

  1. [html]浏览器标签小图标LOGO简单设置

    方式一:如果是一个项目一个LOGO 的话,直接接把图片像素设置成16x16像素,然后改名favicon.ico放在项目根部目录就可以,自动识别的! 方式二:简单设置! 首先找一个图片把像素设置成16x ...

  2. Spring5:事务管理【整合Mybatis】

    Spring 整合Mybatis 1:导入依赖 <dependencies> <!--测试依赖--> <dependency> <groupId>jun ...

  3. Flutter 开发填坑指南

    引言 第一次在使用Flutter是在Ubuntu机器上,但是因为Android Studio还有Sdk配置问题,flutter doctor总是在这一步报错...最近又在win10上配了一下环境(真香 ...

  4. 2019-2020-1 20199308《Linux内核原理与分析》第九周作业

    <Linux内核分析> 第八章 可执行程序工作原理进程的切换和系统的一般执行过程 8.1 知识点 进程调度的时机 ntel定义的中断类型主要有以下几种 硬中断(Interrupt) 软中断 ...

  5. Programmatically mount a Microsoft Virtual Hard Drive (VHD)

    By Pixy https://stackoverflow.com/questions/24396644/programmatically-mount-a-microsoft-virtual-hard ...

  6. [Qt] 默认的槽函数 例如 on_pushButton_clicked()

    在 setupUI 函数里有一句: QMetaObject::connectSlotsByName(QWDialog); 它假设槽函数的名称是 void on_<object name>_ ...

  7. java中ThreadPool的介绍和使用

    文章目录 Thread Pool简介 Executors, Executor 和 ExecutorService ThreadPoolExecutor ScheduledThreadPoolExecu ...

  8. rabbitMQ安装docker版 /权限管理命令

    1.进入docker hub镜像仓库地址:https://hub.docker.com/ 2.搜素rabbitMQ 查询镜像,可以看到多种类型,选择带有web页面的(managment) 3.拉取镜像 ...

  9. SpringCloud入门(十一):Sleuth 与 Zipkin分布式链路跟踪

    现今业界分布式服务跟踪的理论基础主要来自于 Google 的一篇论文<Dapper, a Large-Scale Distributed Systems Tracing Infrastructu ...

  10. 第三方库PyYAML

    建议参考PyYAML Documentation来源:http://pyyaml.org/wiki/PyYAMLDocumentation:http://blog.csdn.net/conquer07 ...