qq_28104781
qq_28104781
采纳率0%
2019-05-07 15:47 阅读 2.1k

springboot 2.0.5 +mysql5.7 +druid ,本地开发测试正常,放到生产就报错

5

**

Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@17b8c0a6] was not registered for synchronization because synchronization is not active
2019-05-07 15:32:54.236 [http-nio-8081-exec-2] INFO  com.alibaba.druid.pool.DruidDataSource -{dataSource-1} inited
DruidDataSource2019-05-07 15:35:01.620 [Druid-ConnectionPool-Create-906728024] ERROR com.alibaba.druid.pool.DruidDataSource -create connection SQLException, url: jdbc:mysql://169.251.179.213:3306/bbbc?useSSL=true&characterEncoding=UTF-8, errorCode 0, state 08S01
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:835)
        at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:455)
        at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:240)
        at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:199)
        at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1510)
        at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1575)
        at com.alibaba.druid.pool.DruidDataSource$CreateConnectionThread.run(DruidDataSource.java:2450)
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:152)
        at com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:955)
        at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:825)
        ... 6 common frames omitted
Caused by: java.net.ConnectException: Connection timed out (Connection timed out)
        at java.net.PlainSocketImpl.socketConnect(Native Method)
        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.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)
        ... 9 common frames omitted**
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

5条回答 默认 最新

  • b1198420279 b1198420279 2019-05-07 15:52

    连接超时,先排除网络问题:
    去线上机器ping 一下169.251.179.213,能ping通的话再检查一下telnet 169.251.179.213 3306,如果也没问题,那基本上就是代码的问题了。

    点赞 评论 复制链接分享
  • asdf3301 asdf3301 2019-05-07 16:58

    数据库链接的问题,生产上telnet 3306端口或用mysql客户端先试一下能不能连上

    点赞 评论 复制链接分享
  • qiangchen1990 qiangchen1990 2019-05-07 17:23

    建议检查:生产环境的是否可以ping通数据库。
    一般云服务商的虚机在互访问时屏蔽了外网ip,都是通过内网ip进行的。169.251.179.213这是一个公网ip。

    点赞 评论 复制链接分享
  • YangChunHua250 YangChunHua250 2019-05-08 15:01

    你的数据库连接是是不是使用了useSSL = true了,而你的服务端没有开启这个,可以把useSSL =true 改为useSSL =false 试试吧

    点赞 评论 复制链接分享
  • weixin_38522294 weixin_38522294 2019-05-27 13:40

    生产环境的是否可以ping通数据库。
    一般云服务商的虚机在互访问时屏蔽了外网ip,都是通过内网ip进行的。169.251.179.213这是一个公网ip

    点赞 评论 复制链接分享

相关推荐