bug日记:Could not create connection to database server.
网上查了很多博客,指出了两个方向
- yml(yaml)里面数据库的配置问题
- mysql-connector-java 的版本号问题
结合我的报错,项目一测试登录,就报错这个,而且错误6012一直重复出现,就像吃了炫迈一样。。。
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@74790343] was not registered for synchronization because synchronization is not active
2022-01-12 13:03:36.814 ERROR 6012 --- [eate-2063581529] com.alibaba.druid.pool.DruidDataSource : create connection SQLException, url: jdbc:mysql://106.12.147.140/hongyan_system_management?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT&rewriteBatchedStatements=true, errorCode 0, state 08001java.sql.SQLNonTransientConnectionException: Could not create connection to database server.at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:110) ~[mysql-connector-java-8.0.25.jar:8.0.25]at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97) ~[mysql-connector-java-8.0.25.jar:8.0.25]at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:89) ~[mysql-connector-java-8.0.25.jar:8.0.25]at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:63) ~[mysql-connector-java-8.0.25.jar:8.0.25]at com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:1006) ~[mysql-connector-java-8.0.25.jar:8.0.25]at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:823) ~[mysql-connector-java-8.0.25.jar:8.0.25]at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:453) ~[mysql-connector-java-8.0.25.jar:8.0.25]at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:246) ~[mysql-connector-java-8.0.25.jar:8.0.25]at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:198) ~[mysql-connector-java-8.0.25.jar:8.0.25]at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1657) ~[druid-1.2.8.jar:1.2.8]at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1723) ~[druid-1.2.8.jar:1.2.8]at com.alibaba.druid.pool.DruidDataSource$CreateConnectionThread.run(DruidDataSource.java:2838) ~[druid-1.2.8.jar:1.2.8]
Caused by: java.time.zone.ZoneRulesException: Unknown time-zone ID: CTTat java.time.zone.ZoneRulesProvider.getProvider(ZoneRulesProvider.java:272) ~[na:1.8.0_271]at java.time.zone.ZoneRulesProvider.getRules(ZoneRulesProvider.java:227) ~[na:1.8.0_271]at java.time.ZoneRegion.ofId(ZoneRegion.java:120) ~[na:1.8.0_271]at java.time.ZoneId.of(ZoneId.java:411) ~[na:1.8.0_271]at java.time.ZoneId.of(ZoneId.java:359) ~[na:1.8.0_271]at com.mysql.cj.protocol.a.NativeProtocol.configureTimeZone(NativeProtocol.java:2191) ~[mysql-connector-java-8.0.25.jar:8.0.25]at com.mysql.cj.protocol.a.NativeProtocol.initServerSession(NativeProtocol.java:2218) ~[mysql-connector-java-8.0.25.jar:8.0.25]at com.mysql.cj.jdbc.ConnectionImpl.initializePropsFromServer(ConnectionImpl.java:1315) ~[mysql-connector-java-8.0.25.jar:8.0.25]at com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:964) ~[mysql-connector-java-8.0.25.jar:8.0.25]... 7 common frames omitted2022-01-12 13:03:36.951 ERROR 6012 --- [eate-2063581529] com.alibaba.druid.pool.DruidDataSource : create connection SQLException, url: jdbc:mysql://106.12.147.140/hongyan_system_management?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT&rewriteBatchedStatements=true, errorCode 0, state 08001java.sql.SQLNonTransientConnectionException: Could not create connection to database server.at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:110) ~[mysql-connector-java-8.0.25.jar:8.0.25]at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97) ~[mysql-connector-java-8.0.25.jar:8.0.25]at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:89) ~[mysql-connector-java-8.0.25.jar:8.0.25]at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:63) ~[mysql-connector-java-8.0.25.jar:8.0.25]at com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:1006) ~[mysql-connector-java-8.0.25.jar:8.0.25]at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:823) ~[mysql-connector-java-8.0.25.jar:8.0.25]at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:453) ~[mysql-connector-java-8.0.25.jar:8.0.25]at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:246) ~[mysql-connector-java-8.0.25.jar:8.0.25]at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:198) ~[mysql-connector-java-8.0.25.jar:8.0.25]at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1657) ~[druid-1.2.8.jar:1.2.8]at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1723) ~[druid-1.2.8.jar:1.2.8]at com.alibaba.druid.pool.DruidDataSource$CreateConnectionThread.run(DruidDataSource.java:2838) ~[druid-1.2.8.jar:1.2.8]
Caused by: java.time.zone.ZoneRulesException: Unknown time-zone ID: CTTat java.time.zone.ZoneRulesProvider.getProvider(ZoneRulesProvider.java:272) ~[na:1.8.0_271]at java.time.zone.ZoneRulesProvider.getRules(ZoneRulesProvider.java:227) ~[na:1.8.0_271]at java.time.ZoneRegion.ofId(ZoneRegion.java:120) ~[na:1.8.0_271]at java.time.ZoneId.of(ZoneId.java:411) ~[na:1.8.0_271]at java.time.ZoneId.of(ZoneId.java:359) ~[na:1.8.0_271]at com.mysql.cj.protocol.a.NativeProtocol.configureTimeZone(NativeProtocol.java:2191) ~[mysql-connector-java-8.0.25.jar:8.0.25]at com.mysql.cj.protocol.a.NativeProtocol.initServerSession(NativeProtocol.java:2218) ~[mysql-connector-java-8.0.25.jar:8.0.25]at com.mysql.cj.jdbc.ConnectionImpl.initializePropsFromServer(ConnectionImpl.java:1315) ~[mysql-connector-java-8.0.25.jar:8.0.25]at com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:964) ~[mysql-connector-java-8.0.25.jar:8.0.25]... 7 common frames omitted
刚开始,只注意了08001,就在wang上查资料,指向的是mysql-connector-java 的版本号问题,就各种尝试,未果。
后来通哥亲自跑了下,指出了控制台的的
Caused by: java.time.zone.ZoneRulesException: Unknown time-zone ID: CTT
唉·,自己眼瞎,还习惯不好,没有好好看控制台,长长记性,下次一定!!!