当前位置:首页 > 开发 > 编程语言 > 数据库连接池 > 正文

关于c3p0建立连接池报错

发表于: 2012-09-18   作者:商人shang   来源:转载   浏览:
摘要:   用c3p0建立连接池,当第一次进行数据库连接的时候,需要初始化很长的时间,而且还会出现以下的错误,在网上搜了很多的东西,有改myeclipse内存配置的,有改Tomcat内存配置的,等等,可是都不管用;还有经常出现的是进行以下的配置   <property name="maxStatements" value="0" /&

 

用c3p0建立连接池,当第一次进行数据库连接的时候,需要初始化很长的时间,而且还会出现以下的错误,在网上搜了很多的东西,有改myeclipse内存配置的,有改Tomcat内存配置的,等等,可是都不管用;还有经常出现的是进行以下的配置

 

<property name="maxStatements" value="0" />
<property name="maxStatementsPerConnection" value="0" />

 可是最终问题还是没有解决,然后找到了一个说是配置初始化连接池的数目必须在min和max之间,然后配置是这样,应该不是这个问题,后来我又自己把initialPoolSize、 minPoolSize和maxPoolSize改成了比较小的数目,现在时不报错了。配置如下:

 

		<property name="maxPoolSize" value="5" />
		<property name="minPoolSize" value="1" />
		<property name="initialPoolSize" value="2" />

 虽然不报错,可是第一次连接数据库的时候还是很慢的,难道连接池不是在Tomcat启动的时候就已经初始化了吗?难道会是在进行第一次连接的时候进行初始化?请大家指点。。。

 

 

 

错误信息如下:

 

Managed Threads: 3

	Active Threads: 3
	Active Tasks: 
		com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@1366e7d (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0)
		com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@900995 (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1)
		com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@6545b3 (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2)
	Pending Tasks: 
		com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@c30cd3
Pool thread stack traces:
	Thread[com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#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:2452)
		com.mysql.jdbc.MysqlIO.readPacket(MysqlIO.java:591)
		com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1070)
		com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2048)
		com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:723)
		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:134)
		com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:182)
		com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:171)
		com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:137)
		com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1014)
		com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:32)
		com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1810)
		com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547)
	Thread[com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#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:2452)
		com.mysql.jdbc.MysqlIO.readPacket(MysqlIO.java:591)
		com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1070)
		com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2048)
		com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:723)
		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:134)
		com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:182)
		com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:171)
		com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:137)
		com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1014)
		com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:32)
		com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1810)
		com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547)
	Thread[com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#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:2452)
		com.mysql.jdbc.MysqlIO.readPacket(MysqlIO.java:591)
		com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1070)
		com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2048)
		com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:723)
		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:134)
		com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:182)
		com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:171)
		com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:137)
		com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1014)
		com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:32)
		com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1810)
		com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547)

关于c3p0建立连接池报错

  • 0

    开心

    开心

  • 0

    板砖

    板砖

  • 0

    感动

    感动

  • 0

    有用

    有用

  • 0

    疑问

    疑问

  • 0

    难过

    难过

  • 0

    无聊

    无聊

  • 0

    震惊

    震惊

编辑推荐
当缺少c3p0.jar包时: 当出现缺少mchange-commons-java-0.2.3.4.jar时 在这里要注意一点:C3p0的版
目前常用的主流Java数据库连接池有:Druid,Proxool,c3p0,DBCP等,他们都是开源项目且使用率极高
目前常用的主流Java数据库连接池有:Druid,Proxool,c3p0,DBCP等,他们都是开源项目且使用率极高
c3p0下载地址:http://download.csdn.net/detail/huhui_bj/6944595 这篇文章介绍的是,在普通Java W
WEB项目中可以使用Tomcat中的连接池,需要在tomcat文件中进行配置,也可以使用自定义的的连接池,自
根据BAE官方文档:bae是不支持连接池的,但今天试验却能实现hibernate c3p0连接池,避免mysql连接超
Hibernate中可以使用默认的连接池,无论功能与性能都不如C3PO(网友反映,我没有测试过),C3P0是一
在log4j.properties中加入: #c3p0 log4j.logger.com.mchange.v2.resourcepool.BasicResourcePool=DE
配置c3p0连接池,启动错误。 spring中c3p0配置xml代码: 项目启动时报以下错误信息: Pool thread s
今天在Spring的配置文件里面配置C3P0数据源: 先导入c3p0的jar包 <bean id="dataSource" name="da
版权所有 IT知识库 CopyRight © 2009-2015 IT知识库 IT610.com , All Rights Reserved. 京ICP备09083238号