ibatis+c3p0错误,各位帮我看看,网上找了好久,都没有解决
2010-01-08 00:01:14[ThreadPoolAsynchronousRunner.java:608:WARN ] com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector@1afd92 -- APPARENT DEADLOCK!!! Creating emergency threads for unassigned pending tasks!
2010-01-08 00:01:14[ThreadPoolAsynchronousRunner.java:624:WARN ] com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector@1afd92 -- APPARENT DEADLOCK!!! Complete Status: 
Managed Threads: 3
Active Threads: 3
Active Tasks: 
com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@101c949 (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0)
com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@460859 (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1)
com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@1ce439e (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2)
Pending Tasks: 
com.mchange.v2.resourcepool.BasicResourcePool$1RefurbishCheckinResourceTask@b956b1
Pool thread stack traces:
Thread[com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1,5,main]
java.lang.Thread.sleep(Native Method)
com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1805)
com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547)
Thread[com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0,5,main]
java.lang.Thread.sleep(Native Method)
com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1805)
com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547)
Thread[com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2,5,main]
java.lang.Thread.sleep(Native Method)
com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1805)
com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547)2010-01-08 00:01:29[  BasicResourcePool.java:1841:WARN ] com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@1ce439e -- 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: 
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failureLast packet sent to the server was 0 ms ago.
at sun.reflect.GeneratedConstructorAccessor77.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1074)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2120)
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:723)
at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:46)
at sun.reflect.GeneratedConstructorAccessor34.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:302)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:282)
at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:134)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:182)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:171)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:137)
at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1014)
at com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:32)
at com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1810)
at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547)
Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failureLast packet sent to the server was 0 ms ago.
at sun.reflect.GeneratedConstructorAccessor77.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1074)
at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:335)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2043)
... 16 more
Caused by: java.net.SocketException: No buffer space available (maximum connections reached?): connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(Unknown Source)
at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:253)
at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:284)
... 17 more

解决方案 »

  1.   

    我c3o0的配置
    acquireIncrement=3
    acquireRetryAttempts=30
    acquireRetryDelay=1000
    autoCommitOnClose=false
    automaticTestTable=t_test
    breakAfterAcquireFailure=true
    checkoutTimeout=10000
    idleConnectionTestPeriod=18000
    minPoolSize=1
    initialPoolSize=1
    maxIdleTime=25000
    maxPoolSize=100
    maxStatements=0
    maxStatementsPerConnection=0
    numHelperThreads=5
    propertyCycle=300
    testConnectionOnCheckin=true
    usesTraditionalReflectiveProxies=false
      

  2.   

    tomcat启动日志.c3p0配置
    2010-01-08 14:55:51[AbstractPoolBackedDataSource.java:462:INFO ] Initializing c3p0 pool... com.mchange.v2.c3p0.ComboPooledDataSource
     acquireIncrement -> 3, 
     acquireRetryAttempts -> 30,
     acquireRetryDelay -> 1000,
     autoCommitOnClose -> false,
     automaticTestTable -> t_test, 
     breakAfterAcquireFailure -> true, 
     checkoutTimeout -> 10000, 
     connectionCustomizerClassName -> null, 
     connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, 
     dataSourceName -> 1hge164863j14wh9egwbg|10d78ec,
     debugUnreturnedConnectionStackTraces -> false,
     description -> null, 
     driverClass -> com.mysql.jdbc.Driver,
     factoryClassLocation -> null,
     forceIgnoreUnresolvedTransactions -> false,
     identityToken -> 1hge164863j14wh9egwbg|10d78ec,
     idleConnectionTestPeriod -> 18000, 
     initialPoolSize -> 1,
     jdbcUrl -> jdbc:mysql://127.0.0.1:3306/htcweb?characterEncoding=GBK,
     maxAdministrativeTaskTime -> 0, 
     maxConnectionAge -> 0,
     maxIdleTime -> 25000, 
     maxIdleTimeExcessConnections -> 0, 
     maxPoolSize -> 100, 
     maxStatements -> 0, 
     maxStatementsPerConnection -> 0, 
     minPoolSize -> 1, 
     numHelperThreads -> 3,
     numThreadsAwaitingCheckoutDefaultUser -> 0,
     preferredTestQuery -> null, properties -> {user=******, password=******},
     propertyCycle -> 300,
     testConnectionOnCheckin -> true, 
     testConnectionOnCheckout -> false, 
     unreturnedConnectionTimeout -> 0, 
     usesTraditionalReflectiveProxies -> false ]
      

  3.   

    java.net.SocketException: No buffer space available (maximum connections reached?): connect 
    连接数占满啦
      

  4.   

    maxIdleTime=25000 
    单位如果是秒的话,idle时间太长了吧也?一般1800秒即30分钟即可。
      

  5.   

    谢谢你的回答,我已经设置了1800,就等待运行情况了这个maxIdleTime=25000设置我是参照
    http://www.blogjava.net/Alpha/archive/2009/03/29/262789.html
    中解决MYSQL 8小时问题的配置。
      

  6.   

    还看到:
    我比较过流行的 dbcp,c3p0,proxool 三种连接池,上网搜集了很多资料,发现都是proxool最好。现在hibernate3中已经放弃了对dbcp的集成,我从hibernate的官方网站上看到hibernate的作者说这样做的原因是因为实践过程中发现dbcp不稳定,至于c3p0,我见过国外有几篇文章讲到它的效率不高,不过具体怎样,我没试过。我们公司的维护的一个日访问量达数十万的网站就是用proxool,事实证明很稳定
    大家有没有用过proxool 。
    真的如上面这么好用吗?
      

  7.   

       嘿嘿,这个谁用谁知道啦
        建议楼主看一下这篇:有数据测试支持结论的。
        http://blog.sina.com.cn/s/blog_493309600100e02g.html
      

  8.   

    IBATIS中整合proxool
    我修改了项目的链接池:参照了下面的网页
    ①下载:proxool-0.9.1.zip:http://proxool.sourceforge.net/download.html
    ②参照了下面的网页:http://wt8414.javaeye.com/blog/514824
    具体操作:
    准备:把proxool-0.9.1.zip包中的proxool-cglib.jar和proxool-0.9.1.jar放入WEB-INF/lib下面。
    java:根据网页中的ProxoolDataSourceFactory,写一个类。添加下面属性
            //house-keeping-sleep-time:
            //自动侦察各个连接状态的时间间隔(毫秒),侦察到空闲的连接就马上回收,超时的销毁,默认值为30秒
            dataSource.setHouseKeepingTestSql((String)map.get("housekeepingsleeptime"));
            //maximum-active-time:
            //线程最大存活时间,超过此时间的线程将被守护线程kill掉,默认值为5分钟
            dataSource.setMaximumActiveTime((Long)map.get("maximumActiveTime"));
            //maximum-connection-count:
            //到数据库的最大连接数,超过了这个连接,再有请求时,就排在队列中等候,最大的等待请求数由simultaneous-build-throttle决定;默认值为15
            dataSource.setMaximumConnectionCount((Integer) map.get("maximumConnectionCount"));
            //maximum-connection-lifetime:
            //连接最大存活时间,毫秒为单位,默认值为4小时
            dataSource.setMaximumConnectionLifetime((Integer) map.get("maximumConnectionLifetime")*1000*3600);
            //minimum-connection-count:
            //不管是否被使用都保持开放的最小连接数,默认值为5
            dataSource.setMinimumConnectionCount((Integer) map.get("minimumConnectionCount"));
            //overload-without-refusal-lifetime:
            //用来判断连接池状态,如果在此选项设置时间内(毫秒为单位)拒绝了连接,则认为过负载。默认值为60秒
            dataSource.setOverloadWithoutRefusalLifetime((Integer) map.get("overloadWithoutRefusalLifetime")*1000);
            //prototype-count:
            //最少保持的空闲连接数,注意与minimum-connection-count区分。默认值为0
            dataSource.setPrototypeCount((Integer) map.get("prototypeCount"));
            //simultaneous-build-throttle:  
            //这是我们可一次建立的最大连接数。那就是新增的连接请求,但还没有可供使用的连接。由于连接可以使用多线程,
            //在有限的时间之间建立联系从而带来可用连接,但是我们需要通过一些方式确认一些线程并不是立即响应连接请求的,默认是10
            dataSource.setSimultaneousBuildThrottle((Integer) map.get("simultaneousBuildThrottle"));
            //statistics:  连接池使用状况统计。 参数“10s,1m,1d”
            dataSource.setStatistics((String)map.get("statistics"));proxool配置:sqlMapConfig.xml也模拟网页中的写法.添加的配置
          <property name="housekeepingsleeptime" value="30"/>
          <property name="maximumActiveTime" value="5"/>  
          <property name="minimumConnectionCount" value="5"/>  
          <property name="maximumConnectionCount" value="15"/>  
          <property name="maximumConnectionLifetime" value="4"/>  
          <property name="overloadWithoutRefusalLifetime" value="60"/>  
          <property name="prototypeCount" value="0"/>  
          <property name="simultaneousBuildThrottle" value="10"/>  
          <property name="statistics" value="10m"/> proxool 连接池配置属性说明详解 :http://www.cnblogs.com/shiyangxt/archive/2009/03/28/1424145.html
    http://blog.sina.com.cn/s/blog_493309600100e02g.html
    http://proxool.sourceforge.net/properties.html
    第一次配置proxool,希望不小心路过的牛人,指点一二。
      

  9.   

    上面java部分:类型转换有点问题,太粗心了。
            //house-keeping-sleep-time:
            //自动侦察各个连接状态的时间间隔(毫秒),侦察到空闲的连接就马上回收,超时的销毁,默认值为30秒
            dataSource.setHouseKeepingTestSql((String)map.get("housekeepingsleeptime"));
            //maximum-active-time:
            //线程最大存活时间,超过此时间的线程将被守护线程kill掉,默认值为5分钟
            dataSource.setMaximumActiveTime(Long.valueOf((String)map.get("maximumActiveTime")));
            //maximum-connection-count:
            //到数据库的最大连接数,超过了这个连接,再有请求时,就排在队列中等候,最大的等待请求数由simultaneous-build-throttle决定;默认值为15
            dataSource.setMaximumConnectionCount(Integer.valueOf((String)map.get("maximumConnectionCount")));
            //maximum-connection-lifetime:
            //连接最大存活时间,毫秒为单位,默认值为4小时
            dataSource.setMaximumConnectionLifetime((Integer.valueOf((String)map.get("maximumConnectionLifetime")) )*1000*3600);
            //minimum-connection-count:
            //不管是否被使用都保持开放的最小连接数,默认值为5
            dataSource.setMinimumConnectionCount(Integer.valueOf( (String) map.get("minimumConnectionCount")) );
            //overload-without-refusal-lifetime:
            //用来判断连接池状态,如果在此选项设置时间内(毫秒为单位)拒绝了连接,则认为过负载。默认值为60秒
            dataSource.setOverloadWithoutRefusalLifetime(Integer.valueOf((String) map.get("overloadWithoutRefusalLifetime"))*1000);
            //prototype-count:
            //最少保持的空闲连接数,注意与minimum-connection-count区分。默认值为0
            dataSource.setPrototypeCount(Integer.valueOf((String)map.get("prototypeCount")));
            //simultaneous-build-throttle:  
            //这是我们可一次建立的最大连接数。那就是新增的连接请求,但还没有可供使用的连接。由于连接可以使用多线程,
            //在有限的时间之间建立联系从而带来可用连接,但是我们需要通过一些方式确认一些线程并不是立即响应连接请求的,默认是10
            dataSource.setSimultaneousBuildThrottle(Integer.valueOf((String) map.get("simultaneousBuildThrottle")));
            //statistics:  连接池使用状况统计。 参数“10s,1m,1d”
            dataSource.setStatistics((String)map.get("statistics"));