使用C3P0连接MySQL 8.0.19数据库出现异常:Unknown system variable 'tx_isolation'

在做架构迁移的时候,使用C3P0连接MySQL 8.0.19数据库出现如下异常:

java.sql.SQLException: Unknown system variable 'tx_isolation'

at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1094)

at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4208)

at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4140)

at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2597)

at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2758)

at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2820)

at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2769)

at com.mysql.jdbc.StatementImpl.executeQuery(StatementImpl.java:1569)

at com.mysql.jdbc.ConnectionImpl.getTransactionIsolation(ConnectionImpl.java:3372)

at com.mchange.v2.c3p0.impl.NewPooledConnection.<init>(NewPooledConnection.java:70)

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

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

at com.mchange.v2.resourcepool.BasicResourcePool.assimilateResource(BasicResourcePool.java:884)

at com.mchange.v2.resourcepool.BasicResourcePool.acquireUntil(BasicResourcePool.java:601)

at com.mchange.v2.resourcepool.BasicResourcePool.access$400(BasicResourcePool.java:31)

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

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

原因:在低版本的MySQL中,tx_isolation是作为transaction_isolation(查询事务隔离级别)的别名被应用的,高版本已经弃用。

解决方法:升级mysql-connector-java.jar的版本。

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值