今天碰到一坑,特此记录
环境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
问题解决
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。