jdbc连接数据库报错communications link failure

项目是springboot2 + netty项目 打成jar包
直接用外部jre运行的
把项目部署在一台电脑上win7x64
mysql版本5.6.26
jdbc驱动5.1.36

项目启动后就报错communications link failure
卡了很久,应该是连接超时了
数据库就装在本地,navicat连接没有一点问题
我又尝试连接我开发电脑的mysql,发现也报相同的错误
又尝试将项目包括mysql部署在其它的电脑上,有的正常有的报错
这是为什么?系统都是win7x64
关键是navicat都可以连接,程序却在有的电脑可以用,有的电脑不行
这是windwos哪里做了限制吗?
druid配置,后来换成HiKariCP也不行,应该不是连接池问题

spring:
  datasource:
    url: jdbc:mysql://127.0.0.1:3306/aaaa?zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=utf8
    username: root
    password: ******
    driver-class-name: com.mysql.jdbc.Driver
    type: com.alibaba.druid.pool.DruidDataSource
    druid:
      initial-size: 100
      min-idle: 5
      maxActive: 500
      maxWait: 60000
      timeBetweenEvictionRunsMillis: 60000
      minEvictableIdleTimeMillis: 300000
      validationQuery: SELECT 1 FROM DUAL
      testWhileIdle: true
      testOnBorrow: true
      testOnReturn: false
      poolPreparedStatements: true
      maxPoolPreparedStatementPerConnectionSize: 20
      filters: stat,wall

错误信息

ERROR com.alibaba.druid.pool.DruidDataSource - init datasource error, url: jdbc:mysql://127.0.0.1:3306/aaaa?zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=utf8
com.mysql.jdbc.exceptions.jdbc4.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 sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_152]

关键,另外一套基于tomcat的ssh的老程序jdk6的,用同一数据库以及驱动,可以连接成功,不过连接池用的c3p0
这样一来就是我程序问题?或者是maven打包把啥不该打包的也搞进去了?
不过有的pc可以有的pc不行没道理啊

阅读 20.3k
3 个回答

太tm煞笔了
公司更新了加密系统不知道咋就把我程序的啥东西加密了
打了补丁就好了。。。。
简直浪费时间

确定127.0.0.1:3306/aaaa 可以访问?用户名/密码正确 ?

我当时是重启下mysql就好了

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题