问答详情
源自:4-8 DAO层单元测试编码和问题排查(上)

测试报错了,好像是sqlSession的问题

警告: com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@67ad6302 -- Acquisition Attempt Failed!!! Clearing pending acquires. While trying to acquire a needed new resource, we failed to succeed more than the maximum number of allowed acquisition attempts (30). Last acquisition attempt exception: 

java.sql.SQLException: 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.

at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:127)

at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:95)

at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:87)

at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:61)

at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:71)

at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:76)

at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:862)

at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:444)

at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:230)

at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:226)

at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:134)

at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:182)

at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:171)

at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:137)

at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1014)

at com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:32)

at com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1810)

at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547)

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.

at sun.reflect.GeneratedConstructorAccessor8.newInstance(Unknown Source)

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)

at java.lang.reflect.Constructor.newInstance(Constructor.java:422)

at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:59)

at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:83)

at com.mysql.cj.util.TimeUtil.getCanonicalTimezone(TimeUtil.java:128)

at com.mysql.cj.protocol.a.NativeProtocol.configureTimezone(NativeProtocol.java:2201)

at com.mysql.cj.protocol.a.NativeProtocol.initServerSession(NativeProtocol.java:2225)

at com.mysql.cj.jdbc.ConnectionImpl.initializePropsFromServer(ConnectionImpl.java:1391)

at com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:993)

at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:852)

... 11 more


数据库的properties信息都是对的,配置也没看出啥问题,这个是什么原因?

提问者:慕哥4102554 2018-07-30 08:37

个回答

  • 慕容2098438
    2018-08-20 17:56:49

    lz解决了吗 我也是这个问题

  • 晴天_yoyo
    2018-08-05 02:07:21

    我猜你是不是这个问题:你改下username试试吧,不要叫做username都行

    https://img3.mukewang.com/5b65eb3300010ba714510604.jpg

  • qq_宫怨柳_04233893
    2018-07-31 20:33:43

    https://img2.mukewang.com/5b6056790001f50112790112.jpg你用的jdbcDrives是高版本的把,在url那里设置时区试试?或者用低版本的驱动


    高版本的是 com.mysql.cj.jdbc.Driver
    低版本的是com.mysql.jdbc.Driver
    jdbc.mysql.url = jdbc:mysql://localhost:3306/jdbctest?useUnicode=true&characterEncoding=UTF8&useSSL=false&serverTimezone=GMT