[分享]c3p0 no bug but the windows xp have_MySQL, Oracle及数据库讨论区_Weblogic技术|Tuxedo技术|中间件技术|Oracle论坛|JAVA论坛|Linux/Unix技术|hadoop论坛_联动北方技术论坛  
网站首页 | 关于我们 | 服务中心 | 经验交流 | 公司荣誉 | 成功案例 | 合作伙伴 | 联系我们 |
联动北方-国内领先的云技术服务提供商
»  游客             当前位置:  论坛首页 »  自由讨论区 »  MySQL, Oracle及数据库讨论区 »
总帖数
1
每页帖数
101/1页1
返回列表
0
发起投票  发起投票 发新帖子
查看: 2277 | 回复: 0   主题: [分享]c3p0 no bug but the windows xp have        下一篇 
solo9867
注册用户
等级:新兵
经验:61
发帖:71
精华:0
注册:2011-12-15
状态:离线
发送短消息息给solo9867 加好友    发送短消息息给solo9867 发消息
发表于: IP:您无权察看 2014-11-11 10:57:17 | [全部帖] [楼主帖] 楼主

5月30日,用了一天的时间在找一个c3p0的bug,但没有找到。31日突然想起来可能是某个原因,于是配置环境->运行,OK 问题解决。

---
经过:最近做了一个SSH2项目,想在项目中使用c3p0连接池,于是就在本地机搭起了项目,配好了 spring管理的连接池c3p0,将项目中用到的mysql数据库放在vmware虚拟机中运行。

可是运行项目的时候,报错,但数据库表却能够生成。
此时,我的主机操作系统是windows xp ,数据库服务器的操作系统也是windows xp.数据库mysql 5.0.22 ,所用用户test1的远程权限已经开通。

报错信息如下:

2010-05-30 12:07:19,046 INFO [org.hibernate.tool.hbm2ddl.SchemaUpdate] - Running hbm2ddl schema update
2010-05-30 12:07:19,046 INFO [org.hibernate.tool.hbm2ddl.SchemaUpdate] - fetching database metadata
2010-05-30 12:07:32,875 WARN [com.mchange.v2.async.ThreadPoolAsynchronousRunner] - com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector@18105e8 -- APPARENT DEADLOCK!!! Creating emergency threads for unassigned pending tasks!
2010-05-30 12:07:32,875 WARN [com.mchange.v2.async.ThreadPoolAsynchronousRunner] - com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector@18105e8 -- APPARENT DEADLOCK!!! Complete Status:
Managed Threads: 3
Active Threads: 3
Active Tasks:
com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask@16d8196 (C3P0PooledConnectionPoolManager-Helper Thread-#2)
com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask@56b93a (C3P0PooledConnectionPoolManager-Helper Thread-#0)
com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask@19abd2b (C3P0PooledConnectionPoolManager-Helper Thread-#1)
Pending Tasks:
com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask@1f98d58
com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask@aea710
com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask@5a2eaa
com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask@adae91
com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask@9fe84e
com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask@4c71d2
com.mchange.v2.resourcepool.BasicResourcePool$1RefurbishCheckinResourceTask@c4bc34
Pool thread stack traces:
Thread[C3P0PooledConnectionPoolManager-Helper Thread-#2,5,main]
java.net.SocketInputStream.socketRead0(Native Method)
java.net.SocketInputStream.read(SocketInputStream.java:129)
com.mysql.jdbc.util.ReadAheadInputStream.fill(ReadAheadInputStream.java:114)
com.mysql.jdbc.util.ReadAheadInputStream.readFromUnderlyingStreamIfNecessary(ReadAheadInputStream.java:161)
com.mysql.jdbc.util.ReadAheadInputStream.read(ReadAheadInputStream.java:189)
com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:2500)
com.mysql.jdbc.MysqlIO.readPacket(MysqlIO.java:600)
com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1079)
com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2186)
com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:787)
com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:49)
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:409)
com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:357)
com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:285)
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:152)
com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1074)
com.mchange.v2.resourcepool.BasicResourcePool.doAcquireAndDecrementPendingAcquiresWithinLockOnSuccess(BasicResourcePool.java:1061)
com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:32)
com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask.run(BasicResourcePool.java:1796)
com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:620)
Thread[C3P0PooledConnectionPoolManager-Helper Thread-#1,5,main]
java.net.SocketInputStream.socketRead0(Native Method)
java.net.SocketInputStream.read(SocketInputStream.java:129)
com.mysql.jdbc.util.ReadAheadInputStream.fill(ReadAheadInputStream.java:114)
com.mysql.jdbc.util.ReadAheadInputStream.readFromUnderlyingStreamIfNecessary(ReadAheadInputStream.java:161)
com.mysql.jdbc.util.ReadAheadInputStream.read(ReadAheadInputStream.java:189)
com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:2500)
com.mysql.jdbc.MysqlIO.readPacket(MysqlIO.java:600)
com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1079)
com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2186)
com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:787)
com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:49)
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:409)
com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:357)
com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:285)
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:152)
com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1074)
com.mchange.v2.resourcepool.BasicResourcePool.doAcquireAndDecrementPendingAcquiresWithinLockOnSuccess(BasicResourcePool.java:1061)
com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:32)
com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask.run(BasicResourcePool.java:1796)
com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:620)
Thread[C3P0PooledConnectionPoolManager-Helper Thread-#0,5,main]
java.net.SocketInputStream.socketRead0(Native Method)
java.net.SocketInputStream.read(SocketInputStream.java:129)
com.mysql.jdbc.util.ReadAheadInputStream.fill(ReadAheadInputStream.java:114)
com.mysql.jdbc.util.ReadAheadInputStream.readFromUnderlyingStreamIfNecessary(ReadAheadInputStream.java:161)
com.mysql.jdbc.util.ReadAheadInputStream.read(ReadAheadInputStream.java:189)
com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:2500)
com.mysql.jdbc.MysqlIO.readPacket(MysqlIO.java:600)
com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1079)
com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2186)
com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:787)
com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:49)
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:409)
com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:357)
com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:285)
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:152)
com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1074)
com.mchange.v2.resourcepool.BasicResourcePool.doAcquireAndDecrementPendingAcquiresWithinLockOnSuccess(BasicResourcePool.java:1061)
com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:32)
com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask.run(BasicResourcePool.java:1796)
com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:620)
2010-05-30 12:07:32,921 INFO [org.hibernate.tool.hbm2ddl.SchemaUpdate] - updating schema
2010-05-30 12:07:33,015 INFO [org.hibernate.tool.hbm2ddl.TableMetadata] - table found: testDB.employee
2010-05-30 12:07:33,015 INFO [org.hibernate.tool.hbm2ddl.TableMetadata] - columns: [username, gender, password]
2010-05-30 12:07:33,015 INFO [org.hibernate.tool.hbm2ddl.TableMetadata] - foreign keys: []
2010-05-30 12:07:33,015 INFO [org.hibernate.tool.hbm2ddl.TableMetadata] - indexes: [primary]
2010-05-30 12:07:33,015 INFO [org.hibernate.tool.hbm2ddl.SchemaUpdate] - schema update complete
2010-05-30 12:07:33,125 INFO [org.springframework.orm.hibernate3.HibernateTransactionManager] - Using DataSource [com.mchange.v2.c3p0.ComboPooledDataSource [ acquireIncrement -> 5, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 0, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, dataSourceName -> 1hge13i881s7ax0b2yw8gy|17494c8, debugUnreturnedConnectionStackTraces -> false, description -> null, driverClass -> org.gjt.mm.mysql.Driver, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, identityToken -> 1hge13i881s7ax0b2yw8gy|17494c8, idleConnectionTestPeriod -> 60, initialPoolSize -> 10, jdbcUrl -> jdbc:mysql://192.168.1.165:3306/testDB?useUnicode=true&characterEncoding=UTF-8, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime -> 60, maxIdleTimeExcessConnections -> 0, maxPoolSize -> 30, maxStatements -> 0, maxStatementsPerConnection -> 0, minPoolSize -> 5, numHelperThreads -> 3, numThreadsAwaitingCheckoutDefaultUser -> 0, preferredTestQuery -> null, properties -> {user=******, password=******}, propertyCycle -> 0, statementCacheNumDeferredCloseThreads -> 0, statementDestroyerNumActiveThreads -> -1, statementDestroyerNumConnectionsInUseAllUsers -> -1, statementDestroyerNumConnectionsInUseDefaultUser -> -1, statementDestroyerNumConnectionsWithDeferredDestroyStatementsAllUsers -> -1, statementDestroyerNumConnectionsWithDeferredDestroyStatementsDefaultUser -> -1, statementDestroyerNumDeferredDestroyStatementsAllUsers -> -1, statementDestroyerNumDeferredDestroyStatementsDefaultUser -> -1, statementDestroyerNumIdleThreads -> -1, statementDestroyerNumTasksPending -> -1, statementDestroyerNumThreads -> -1, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, unreturnedConnectionTimeout -> 0, usesTraditionalReflectiveProxies -> false ]] of Hibernate SessionFactory for HibernateTransactionManager


不管怎样调整c3p0的运行参数,都没办法找到错误的所在,表面看就是无法获得连接。
但我把项目拷贝到数据库服务器上,让程序和数据库处于同一机器上时,再运行,错误没有了,运行速度很快。

从上面的情况来看,有两种可能:一是网络这个环节上出了问题,不能正常处理数据库的请求数据。二是c3p0有问题,在本地机可以很好地运行,在网 络协议上的处理上有不正常的的地方。但这两种可能我都觉得不太可能,因为无论是网络还是c3p0都不是一天两天的东西了,存在这种低级问题的可能很小。

可问题依然存在,夜不能寐....。

第二日,猛然想起来,记得当年windows xp sp3发布以后,曾经限制过TCP/IP的连接,会不会是这个东东在作怪呢?赶紧在vmware 的windows 2003 server服务器上安装上mysql 5.0.22,配置好帐号的远程访问权限。项目运行OK

至此,问题终于得到解决。

原因:因为windows xp限制了TCP/IP的并发数量,如果我们用xp做服务器,单机开发是没有问题的,这时,我们登录数据库都是一个用户,一个连接。但用了连接池以后,就 是一个用户,多个连接了,这时候xp的限制作用就生效了。
所以,在项目中使用数据库服务器的时候,其操作系统最好选择server版本的,否则,出现问题很不好查。

我在网上查错误的时候,发现好多人都说这是c3p0的bug,在此特更正一下,出现这种错误,多数是环境问题,尤其是windows xp作服务器的情况下。

C3p0 no bug but the windows xp have


顺便说一下,c3p0的0.9.2-pre1版也在5月27日发布了。 

--转自 北京联动北方科技有限公司




赞(0)    操作        顶端 
总帖数
1
每页帖数
101/1页1
返回列表
发新帖子
请输入验证码: 点击刷新验证码
您需要登录后才可以回帖 登录 | 注册
技术讨论