解决: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 ...
随机推荐
- 4. js
1.) ~ 操作符 console.log(~-2) // 1 console.log(~-1) // 0 console.log(~0) // -1 console.log(~1) // ...
- frp内网穿透学习
前言 因为自己在内网,但是目标站在外网,这时候可以通过内网穿透工具,将接收到的请求转发到内网,实现在内网的msf可以控制外网的靶机. 也看了一些Ngrok,花生壳的,发现Ngrok.cc这个看文章说有 ...
- [De1CTF 2019]SSRF Me
原帖地址 : https://xz.aliyun.com/t/5927 De1CTF 2019 的一个题目总结 题目描述 直接查看页面源代码可以看到正确格式的代码 #! /usr/bin/env py ...
- shiro:加密及密码比对器(三)
基于[自定义remle(二)]项目增加加密功能 1:数据库t_user表增加一列(盐) 增加字段:salt CREATE TABLE `t_user` ( `id` int(11) NOT NULL ...
- Spring5:控制反转
二.Spring IOC控制反转 1:IOC推导 >传统业务调用编程 定义一个userDao接口:UserDao package com.spring; public interface Use ...
- php phpStudy session存放位置
如果你仅仅是想知道session保存的文件在哪里,你可以在你的PHP文件当中运行函数:session_save_path之后查看运行结果即可知道session文件的存放目录. 或者: 在php-ini ...
- 必应每日图片api
https://cn.bing.com/HPImageArchive.aspx?format=xml&cc=jp&idx=0&n=1 format = 'xml' | 'j ...
- python学习20之面向对象编程高级
'''''''''1.动态绑定:对于一个类,我们可以对它的实例动态绑定新的属性或方法.为了使所有的实例均可以使用动态绑定的属性和方法,我们也可以采用对类直接动态绑定'''class Student() ...
- Python(5)
把 aaabbcccd 这种形式的字符串压缩成 a3b2c3d1 这种形式. print(''.join({i+str(s.count(i)) for i in s})) dic={} for i i ...
- dns的抓包分析
dns: 域名系统(服务)协议 dns的解析全过程: 1. 浏览器先检查自身缓存中有没有被解析过的这个域名对应的ip地址,如果有,解析结束.同时域名被缓存的时间也可通过TTL属性来设置. 2. 如果浏 ...