mysql,ibatis c3p0连接池错误

配置c3p0连接池,启动错误。

spring中c3p0配置xml代码:
mysql,ibatis c3p0连接池错误_第1张图片
 项目启动时报以下错误信息:

Pool thread stack traces:
 Thread[C3P0PooledConnectionPoolManager[identityToken->1hge1648v7x7xsqhft1n|1e3a43]-HelperThread-#1,5,main]
  java.net.SocketInputStream.socketRead0(Native Method)
  java.net.SocketInputStream.read(SocketInputStream.java:129)
  com.mysql.jdbc.util.ReadAheadInputStream.fill(ReadAheadInputStream.java:113)
  com.mysql.jdbc.util.ReadAheadInputStream.readFromUnderlyingStreamIfNecessary(ReadAheadInputStream.java:160)
  com.mysql.jdbc.util.ReadAheadInputStream.read(ReadAheadInputStream.java:188)
  com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:2428)
  com.mysql.jdbc.MysqlIO.readPacket(MysqlIO.java:590)
  com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1069)
  com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2031)
  com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:718)
  com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:46)
  sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
  sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
  sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
  java.lang.reflect.Constructor.newInstance(Constructor.java:513)
  com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
  com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:302)
  com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:282)
  com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:146)
  com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:195)
  com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:184)
  com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:200)
  com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1086)
  com.mchange.v2.resourcepool.BasicResourcePool.doAcquireAndDecrementPendingAcquiresWithinLockOnSuccess(BasicResourcePool.java:1073)
  com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:44)
  com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask.run(BasicResourcePool.java:1810)
  com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:648)
 Thread[C3P0PooledConnectionPoolManager[identityToken->1hge1648v7x7xsqhft1n|1e3a43]-HelperThread-#0,5,main]
  java.net.SocketInputStream.socketRead0(Native Method)
  java.net.SocketInputStream.read(SocketInputStream.java:129)
  com.mysql.jdbc.util.ReadAheadInputStream.fill(ReadAheadInputStream.java:113)
  com.mysql.jdbc.util.ReadAheadInputStream.readFromUnderlyingStreamIfNecessary(ReadAheadInputStream.java:160)
  com.mysql.jdbc.util.ReadAheadInputStream.read(ReadAheadInputStream.java:188)
  com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:2428)
  com.mysql.jdbc.MysqlIO.readPacket(MysqlIO.java:590)
  com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1069)
  com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2031)
  com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:718)
  com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:46)
  sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
  sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
  sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
  java.lang.reflect.Constructor.newInstance(Constructor.java:513)
  com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
  com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:302)
  com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:282)
  com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:146)
  com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:195)
  com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:184)
  com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:200)
  com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1086)
  com.mchange.v2.resourcepool.BasicResourcePool.doAcquireAndDecrementPendingAcquiresWithinLockOnSuccess(BasicResourcePool.java:1073)
  com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:44)
  com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask.run(BasicResourcePool.java:1810)
  com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:648)
 Thread[C3P0PooledConnectionPoolManager[identityToken->1hge1648v7x7xsqhft1n|1e3a43]-HelperThread-#2,5,main]
  java.net.SocketInputStream.socketRead0(Native Method)
  java.net.SocketInputStream.read(SocketInputStream.java:129)
  com.mysql.jdbc.util.ReadAheadInputStream.fill(ReadAheadInputStream.java:113)
  com.mysql.jdbc.util.ReadAheadInputStream.readFromUnderlyingStreamIfNecessary(ReadAheadInputStream.java:160)
  com.mysql.jdbc.util.ReadAheadInputStream.read(ReadAheadInputStream.java:188)
  com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:2428)
  com.mysql.jdbc.MysqlIO.readPacket(MysqlIO.java:590)
  com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1069)
  com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2031)
  com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:718)
  com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:46)
  sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
  sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
  sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
  java.lang.reflect.Constructor.newInstance(Constructor.java:513)
  com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
  com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:302)
  com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:282)
  com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:146)
  com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:195)
  com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:184)
  com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:200)
  com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1086)
  com.mchange.v2.resourcepool.BasicResourcePool.doAcquireAndDecrementPendingAcquiresWithinLockOnSuccess(BasicResourcePool.java:1073)
  com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:44)
  com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask.run(BasicResourcePool.java:1810)
  com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:648)

解决办法:

更改配置文件里的最大连接数和初始化连接数大小:

xml代码:


数据库的连接数是有限的,每次应用启动C3p0都会占用数据库的连接来填充C3p0的连接池,而当数据库的资源被占光时就会因为无法获得共享资源而报死锁。

你可能感兴趣的:(ibatis)