解决:com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure(真实有效)
数据库连接失败
一、例如我在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(真实有效)的更多相关文章
- 【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 ...
- 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 ...
- Java连接MySQL报错:CommunicationsException: Communications link failure
现象: 报错:Exception in thread "main" com.mysql.cj.jdbc.exceptions.CommunicationsException: Co ...
- 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 ...
- 异常解决:Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
异常描述 这个异常通常有如下信息: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failu ...
- mysql 5.1超过默认8小时空闲时间解决办法(错误:com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure)
报错: MySQL第二天早上第一次连接超时报错, com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications lin ...
- Cause: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure 解决
感谢大佬:https://blog.csdn.net/a704397849/article/details/93797529 springboot + mybatis多数据库 + druid连接池配置 ...
- com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure 数据库报错
-- 查询mysql 数据库链接空闲时间持有最大空闲时间,单位为秒 SHOW VARIABLES WHERE VAriable_name = 'interactive_timeout'; -- 会出现 ...
- 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 ...
随机推荐
- 今天我们谈一下HTML标签中的<map>标签的用法和使用场景
首先我们看下这个标签到底是干什么的! W3C的定义: 然后兼容性: 然后与之配套使用的另一个标签: <area/>规定其区域: 我们来看看<map>标签支不支持全局属性:=== ...
- 本地同时使用多个git账号
config文件说明 Git Document指示在首次安装git的时候需要配置Config的相关内容信息,有三个地方存储了config文件,决定了读取的场景不同. 1 /etc/gitconfig: ...
- python-Django收集主机信息json格式
Control: from django.conf.urls import patterns, include, url from django.contrib import admin admin. ...
- Java IO 流-- 文件拷贝
IO流操作套路: 1.创建源: 2.选择流: 3.操作: 4.释放资源 上代码: package com.xzlf.io; import java.io.File; import java.io.Fi ...
- Samba远程Shell命令注入执行漏洞
CVE:CVE-2007-2447 原理: Samba中负责在SAM数据库更新用户口令的代码未经过滤便将用户输入传输给了/bin/sh.如果在调用smb.conf中定义的外部脚本时,通过对/bin/s ...
- (三)PL/SQL数据类型
PL/SQL注释 程序注释是解释性说明,可以包括自己编写的,并帮助任何人阅读源代码的PL/SQL代码.所有的编程语言允许某种形式的注释. 在PL/SQL支持单行和多行注释.任何注释里面所有字符都会被P ...
- How to change the header background color of a QTableView
You can set the style sheet on the QTableView ui->tableView->setStyleSheet("QHeaderView:: ...
- Decision tree——决策树
基本流程 决策树是通过分次判断样本属性来进行划分样本类别的机器学习模型.每个树的结点选择一个最优属性来进行样本的分流,最终将样本类别划分出来. 决策树的关键就是分流时最优属性$a$的选择.使用所谓信息 ...
- Apple Watch Series 6或将增加焦虑监测和睡眠追踪功能
一条新的泄露消息称,Apple Watch Series 6 将增加心理健康功能,延长电池续航时间,并对现有传感器进行扩展,这样设备可以测量血液含氧量.苹果即将更新的 Apple Watch 新款推测 ...
- spark下dataframe转为rdd格式
dataframe可以实现很多操作,但是存储到本地的时候,只能存 parquest格式 需要存储源格式,需要转换为rdd类型 将dataframe中的每一行都map成有逗号相连的string,就变为了 ...