前后出现的几个关键错误信息
java.sql.SQLException: Unknown system variable ‘tx_isolation’
java.lang.RuntimeException: java.sql.SQLException: Connections could not be acquired from the underlying database!
Caused by: java.sql.SQLException: Connections could not be acquired from the underlying database!
Caused by: com.mchange.v2.resourcepool.CannotAcquireResourceException: A ResourcePool could not acquire a resource from its primary factory or source.
背景
maven+spring的演示demo
MySQL的版本:
连接池的datasource的四项配置:
jdbc的版本:
问题
运行之后,
首先出现的是这样的错误:
五月 11, 2020 4:26:41 下午 com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask run
警告: com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@1bfed88e -- 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: Unknown system variable 'tx_isolation'
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1055)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
...
...
java.lang.RuntimeException: java.sql.SQLException: Connections could not be acquired from the underlying database!
at com.veeja.dao.impl.AccountDaoImpl.findAll(AccountDaoImpl.java:29)
at com.veeja.service.impl.AccountServiceImpl.findAllAccount(AccountServiceImpl.java:23)
...
...
Caused by: java.sql.SQLException: Connections could not be acquired from the underlying database!
at com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.java:106)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:529)
...
...
Caused by: com.mchange.v2.resourcepool.CannotAcquireResourceException: A ResourcePool could not acquire a resource from its primary factory or source.
at com.mchange.v2.resourcepool.BasicResourcePool.awaitAvailable(BasicResourcePool.java:1319)
at com.mchange.v2.resourcepool.BasicResourcePool.prelimCheckoutResource(BasicResourcePool.java:557)
...
...
这个问题,是因为我们的mysql版本太高,而jdbc版本跟不上。
这个时候我们要么把mysql给降级,要么把jdbc给升级,哈哈哈,那还不是废话吗,当然是改一下jdbc的版本,毕竟是maven项目,动动就完事了。
改成:
然而又出现了这样的错误,关键信息在于java.sql.SQLException: The server time zone value ‘�й���ʱ��’ is unrecognized or represents
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.
五月 11, 2020 4:39:58 下午 com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask run
警告: com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@5dcd76d7 -- 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:129)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
...
...
我们需要添加一个servertime之类的玩意,稍微做更改:
试运行:
成功了。
我套他猴子,一波三折,浪费我甚多时间哪~~