• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

c3p0连接池:com.mysql.cj.exceptions.InvalidConnectionAttributeException

原作者: [db:作者] 来自: [db:来源] 收藏 邀请
 1 四月 17, 2019 10:21:13 上午 com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource getPoolManager
 2 信息: Initializing c3p0 pool... com.mchange.v2.c3p0.ComboPooledDataSource [ acquireIncrement -> 3, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 0, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, dataSourceName -> 2udui8a2beimx6x8ptry|2f4d3709, debugUnreturnedConnectionStackTraces -> false, description -> null, driverClass -> com.mysql.jdbc.Driver, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, identityToken -> 2udui8a2beimx6x8ptry|2f4d3709, idleConnectionTestPeriod -> 0, initialPoolSize -> 20, jdbcUrl -> jdbc:mysql://localhost:3306/test, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime -> 30, maxIdleTimeExcessConnections -> 0, maxPoolSize -> 30, maxStatements -> 0, maxStatementsPerConnection -> 0, minPoolSize -> 10, numHelperThreads -> 3, numThreadsAwaitingCheckoutDefaultUser -> 0, preferredTestQuery -> null, properties -> {user=******, password=******}, propertyCycle -> 0, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, unreturnedConnectionTimeout -> 0, usesTraditionalReflectiveProxies -> false ]
 3 Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.
 4 四月 17, 2019 10:21:33 上午 com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector run
 5 警告: com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector@26aa877c -- APPARENT DEADLOCK!!! Creating emergency threads for unassigned pending tasks!
 6 四月 17, 2019 10:21:33 上午 com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector run
 7 警告: com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector@26aa877c -- APPARENT DEADLOCK!!! Complete Status: 
 8     Managed Threads: 3
 9     Active Threads: 3
10     Active Tasks: 
11     ....    
12 Caused by: com.mysql.cj.exceptions.InvalidConnectionAttributeException: The server time zone value '???ú±ê×??±??' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support.
13     at sun.reflect.GeneratedConstructorAccessor32.newInstance(Unknown Source)
14     at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
15     at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
16     at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:61)
17     at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:85)
18     at com.mysql.cj.util.TimeUtil.getCanonicalTimezone(TimeUtil.java:132)
19     at com.mysql.cj.protocol.a.NativeProtocol.configureTimezone(NativeProtocol.java:2234)
20     at com.mysql.cj.protocol.a.NativeProtocol.initServerSession(NativeProtocol.java:2258)
21     at com.mysql.cj.jdbc.ConnectionImpl.initializePropsFromServer(ConnectionImpl.java:1319)
22     at com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:966)
23     at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:825)
24     ... 11 more

 

2 解析

参考博客地址:https://blog.csdn.net/weixin_37577564/article/details/80329775

 

the server time zone value '???ú±ê×??±??' is unrecognized or represents more than one time zone. 

出现这个的原因是因为 mysql返回的时间总是有问题,比实际时间要早8小时。

jdbc连接的url后面加上serverTimezone=GMT即可解决问题,如果需要使用gmt+8时区,需要写成GMT%2B8

 

3 解决方法

注意:首先检查mysql-connector-java-xxx.jar的版本,若过低,升成8.0.13

 

3.1 如果是在Java工具类里:

 

dataSource.setJdbcUrl("jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8&useSSL=false");

 

3.2 如果是在配置文件里:

<property name="jdbcUrl">jdbc:mysql://localhost:3306/test?useUnicode=true&amp;characterEncoding=utf8&amp;serverTimezone=GMT%2B8&amp;useSSL=false</property>

 

以上,吼吼

 

 


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C文件常见操作发布时间:2022-07-13
下一篇:
C#文本文件读写发布时间:2022-07-13
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap