MySql教程

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

本文主要是介绍com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

客户服务器环境接口访问数据库报错

2021-10-28 10:32:47.566 ERROR 11664 --- [eate-1185788518] com.alibaba.druid.pool.DruidDataSource : create connection SQLException, url: jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8, errorCode 0, state 08S01

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

原因是因为 mysql驱动包和数据库版本差异导致的,项目中驱动是8.0以上的,而客户环境是MySQL数据库是5.6.46版本的。

解决方案1:

将mysql-connector-java驱动降低版本为6.0.1

解决方案2:

&useSSL=false

jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2B8, errorCode 0, state 08S01

解决方案3:

spring.datasource.testWhileIdle= true

spring.datasource.testOnBorrow= true

这篇关于com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!