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

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

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
    at com.mysql.cj.jdbc.exceptions.SQLError.createCommunicationsException(SQLError.java:174)
    at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:64)
    at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:827)
    at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:447)
    at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:237)
    at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:199)
    at java.sql.DriverManager.getConnection(DriverManager.java:664)
    at java.sql.DriverManager.getConnection(DriverManager.java:247)
    at com.baomidou.mybatisplus.generator.config.DataSourceConfig.getConn(DataSourceConfig.java:183)
    at com.baomidou.mybatisplus.generator.config.builder.ConfigBuilder.handlerDataSource(ConfigBuilder.java:270)
    at com.baomidou.mybatisplus.generator.config.builder.ConfigBuilder.<init>(ConfigBuilder.java:136)
    at com.baomidou.mybatisplus.generator.AutoGenerator.execute(AutoGenerator.java:92)
    at com.chinanums.order.admin.code.CodeGenerator.main(CodeGenerator.java:104)
Caused by: com.mysql.cj.exceptions.CJCommunicationsException: Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:61)
    at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:105)
    at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:151)
    at com.mysql.cj.exceptions.ExceptionFactory.createCommunicationsException(ExceptionFactory.java:167)
    at com.mysql.cj.protocol.a.NativeSocketConnection.connect(NativeSocketConnection.java:91)
    at com.mysql.cj.NativeSession.connect(NativeSession.java:150)
    at com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:947)
    at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:817)
    ... 10 more
Caused by: java.net.ConnectException: Connection timed out: connect
    at java.net.DualStackPlainSocketImpl.connect0(Native Method)
    at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79)
    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
    at java.net.Socket.connect(Socket.java:589)
    at com.mysql.cj.protocol.StandardSocketFactory.connect(StandardSocketFactory.java:155)
    at com.mysql.cj.protocol.a.NativeSocketConnection.connect(NativeSocketConnection.java:65)
    ... 13 more
Exception in thread "main" java.lang.NullPointerException
    at com.baomidou.mybatisplus.generator.config.builder.ConfigBuilder.getTablesInfo(ConfigBuilder.java:442)
    at com.baomidou.mybatisplus.generator.config.builder.ConfigBuilder.handlerStrategy(ConfigBuilder.java:282)
    at com.baomidou.mybatisplus.generator.config.builder.ConfigBuilder.<init>(ConfigBuilder.java:143)
    at com.baomidou.mybatisplus.generator.AutoGenerator.execute(AutoGenerator.java:92)
    at com.chinanums.order.admin.code.CodeGenerator.main(CodeGenerator.java:104)

因为是使用的公司内的数据库,没有连接到数据库,所以才报这样的异常。

能够连接上公司内的数据库,就不会出现这样的异常情况了’

原文地址:https://www.cnblogs.com/qingmuchuanqi48/p/12258432.html

时间: 2024-08-15 02:02:21

com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure的相关文章

解决: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 s

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

现象: 报错:Exception in thread "main" com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure 解决办法: 更换 mysql-connector-java-8.0.11.jar 为 mysql-connector-java-8.0.16.jar, 下载位置:https://mvnrepository.com/artifact/mysql/mysql-c

JDBC 报错 CommunicationsException: Communications link failure

|--报错内容 com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server. at com.mysql.cj.jdbc.exceptions

Druid+mysql+mybatis做定时批量操作出现CommunicationsException: Communications link failure

最近使用Druid+mysql+mybatis实现定时批量操作,过一段时间就会抛出 2019-08-21 11:43:51.731 [task-3] ERROR com.alibaba.druid.pool.DruidPooledStatement - CommunicationsException, druid version 1.1.17, jdbcUrl : jdbc:mysql://localhost:3306/bim?serverTimezone=Asia/Shanghai&zeroD

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

启动Tomcat时,发生如下异常: DEBUG resourcepool.BasicResourcePool  - An exception occurred while acquiring a poolable resource. Will retry. com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure The last packet sent successfully to

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

-- 查询mysql 数据库链接空闲时间持有最大空闲时间,单位为秒 SHOW VARIABLES WHERE VAriable_name = 'interactive_timeout'; -- 会出现wait_timeout与该参数意思相近,修改时,一起修改 SHOW VARIABLES WHERE VAriable_name = '%timeout'; -- 解决问题 com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Commun

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

报错: MySQL第二天早上第一次连接超时报错, com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure 原因: 上述问题是由mysql5数据库的配置引起的.mysql5将其连接的等待时间(wait_timeout .interactive_timeout)缺省为8小时.在其客户程序中可以这样来查看其值: mysql> show global variables like 'wait

Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

1.错误描述 [ERROR:]2015-11-05 14:37:52,558 [插入失败] report.service.impl.ReportServiceImpl org.hibernate.exception.JDBCConnectionException: error executing work at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegat

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

21:37:08,815 DEBUG BasicResourcePool:1831 - An exception occurred while acquiring a poolable resource. Will retry.com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure The last packet sent successfully to the server was