今天碰到一坑,特此记录环境springboot2 mysql-connector-java 8.0.15连接mysql5.6出现问题:
java.sql.SQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up.
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:110) ~[mysql-connector-java-8.0.15.jar:8.0.15]
链接url:
url: jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf8&autoReconnect=true&useSSL=false
代码在其他机器上测试过的,确定是mysql版本引起的,搜了一下,各种各样的问题,最终都没有解决。
测试过程中发现加入了
&serverTimezone=GMT%2B8即完整url:
url: jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf8&autoReconnect=true&useSSL=false&serverTimezone=GMT%2B8
问题解决
springboot2 连接mysql5.6时的问题
作者:
在
发表回复