数据库连接失败

一、例如我在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. Mac剪切板中的PNG保存到文件swift

    SwiftGG 教程大全 中文翻译 命令行工具开发教程 Line Programs on macOS Tutorial swift4,较详细 Swift基础中需要注意的点 NSPasteboard M ...

  2. pytorch 文本情感分类和命名实体识别NER中LSTM输出的区别

    文本情感分类: 文本情感分类采用LSTM的最后一层输出 比如双层的LSTM,使用正向的最后一层和反向的最后一层进行拼接 def forward(self,input): ''' :param inpu ...

  3. spring-boot-lll-starter自动化框架介绍

    1. spring-boot-lll-starter自动化框架介绍 1.1. 前言 舔着脸来介绍一波我刚写的自动化框架,spring-boot-lll-starter框架是经由我企业实战总结的一套,适 ...

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

    <Linux内核分析> 第一章 计算机工作原理 1.1 存储程序计算机工作模型 冯·诺依曼体系结构 各种计算机体系结构需要遵从的一个"客观规律" 结构图 冯·诺依曼体系 ...

  5. Kubernetes 命令行工具之kubctl

    目录 1.何为kubectl 2.Kubectl基本使用 2.1.命令补全 2.2.快速查找资源 2.3.使用自定义输出格式 3.陈述式管理资源 3.1.管理namespace资源 3.2.管理Dep ...

  6. POJ3460 Booksort

    飞来山上千寻塔,闻说鸡鸣见日升. 不畏浮云遮望眼,自缘身在最高层.--王安石 题目:Booksort 网址:http://poj.org/problem?id=3460 Description The ...

  7. office 365 激活

    将以下代码复制到记事本 @echo off title Activate Microsoft Office ALL versions &echo - Microsoft Office Prof ...

  8. 使用react脚手架create-react-app创建react应用

    Create React App是一种官方支持的创建单页React应用程序的方法.它提供了一个没有配置的现代构建设置. 一.全局安装脚手架: npm install -g create-react-a ...

  9. Swift-Realm数据库的使用详解

    Swift-Realm数据库的使用详解 概述 Realm 是一个跨平台的移动数据库引擎,其性能要优于 Core Data 和 FMDB - 移动端数据库性能比较, 我们可以在 Android 端 re ...

  10. 网速慢?不!可能是DNS出了问题! 公共DNS优选之 BAT 百度、腾讯、阿里、谷歌DNS哪个更快?

    如果一下还是解决不了你的问题请这边走 首先是Google的DNS: 8.8.8.8 丢包严重 PASS但是扶墙的时候是必备的,如果有扶墙的需求的话可以备用. 二.百度DNS 180.76.76.76 ...