求助:c3p0不定期出现SQLException:Anhacking attemptt 异常

paip.提升稳定性---c3p0数据库连接池不能取到连接An attempt by a client to
paip.提升稳定性---c3p0数据库连接池不能取到连接An attempt by a clientto checkout a Connection has timed out
分类: perf性能优化
:07 7880人阅读 评论
paip.提升稳定性---c3p0数据库连接池不能取到连接An attempt by a client to checkouta Connection has timed out作者Attilax 艾龙, EMAIL:@ 来源:attilax的专栏地址:/attilax最开始,卡死,不动了,,使用jprofile,thread dump...原来是在getconn()在wait..默认添加设置#当连接池用完时客户端调用getConnection()后等待获取新连接的时间,超时后将抛出
#SQLException,如设为0则无限期等待。单位毫秒,默认为0 c3p0.checkoutTimeout=此时,取得conn不到报错。c3p0连接错误An attempt by a client to checkout a Connection has timedout----根本原因:池中的连接已经被全部使用完了..达到了最大maxconn...从而导治这个错误...----其他原因:忘记closeconn,或者异常了而没有close conn,没有释放conn从池中。。...导治池中的conn满的了...、、、、、解决方法: a.适当加大maxPoolSize和minPoolSize ,可以大大缓解这种情况。。c3p0.maxPoolSize=.minPoolSize=10b.检测代码 closeconn..释放conn...当然这个总是有遗漏.最小化这个影响就好..c.自动超时回收Connection(强烈推荐)c3p0.unreturnedConnectionTimeout=25default : 0 单位s为0的时候要求所有的Connection在应用程序中必须关闭。如果不为0,则强制在设定的时间到达后回收Connection,所以必须小心设置,保证在回收之前所有数据库操作都能够完成。这种限制减少Connection未关闭情况的不是很适用。为0不对connection进行回收,即使它并没有关闭。d.配置超时自动断开conn(推荐)c3p0.maxIdleTimeExcessConnections=20c3p0.maxConnectionAge=20 default: 0 单位s配置连接的生存时间,超过这个时间的连接将由连接池自动断开丢弃掉。当然正在使用的连接不会马上断开,而是等待它close再断开。配置为0的时候则不会对连接的生存时间进行限制。e.最后,showfull processlist
..查看dbconn数,,稳定后走ok...否则适当调整以上参数..------------还有一种说法。c3p0.max_statements设置成0可以解决。时间忙,没有验证。。。网上很多说是C3P0的bug问题。c3p0在同时关闭statement和connection的时候,或者关闭他们之间的时间很短的时候,有时候connection并没有被关闭,因为有些preparedstatement还在被cached住。这样就会有很多connection并没有真正的被关闭,连接池的连接都给耗尽了,就会产生上面的异常。解决的方案就是把缓存关闭也就是把c3p0.max_statements设置成0,这样就不会有缓存的preparedstatement,而设置的c3p0.idle_test_period又小于c3p0.timeout,这样的设置应该没有什么问题了。
paip.提升稳定性---c3p0数据库连接池不能取到连接An attempt by a client to由用户自行发布,paip.提升稳定性---c3p0数据库连接池不能取到连接An attempt by a client to内容不代表本站立场,请自行分辨真伪。求助:c3p0不定期出现SQLException:An attempt 异常_百度知道
求助:c3p0不定期出现SQLException:An attempt 异常
我有更好的答案
可能也基本能catch,runtimeexception那得看你catch的是什么异常喽,属于运行时态的异常,但是有些异常,通常的异常都是继承普通的Exception
其他类似问题
为您推荐:
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁求助:c3p0不定期出现SQLException:An attempt 异常_百度知道
求助:c3p0不定期出现SQLException:An attempt 异常
提问者采纳
得看你catch的是什么异常喽,你要特殊定义出来捕捉才能捕捉到,属于运行时态的异常,可能也基本能catch,runtimeexception,但是有些异常,通常的异常都是继承普通的Exception
来自团队:
其他类似问题
为您推荐:
c3p0的相关知识
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁求助:c3p0不定期出现SQLException:An attempt 异常_百度知道
求助:c3p0不定期出现SQLException:An attempt 异常
提问者采纳
严重怀疑为表的联机空间将满导致;此种方法还未试过:java,在该库中重新建立了一个新的表空间以及用户.4,此处未在处理:create profile test_profile limit connect_time unlimited idle_time unlimited、show parameter resourceoracle报错.SQLE如,由于其他工作:alter user comm profile test_profile,发现不是此处的问题、alter system set resource_limit=true,周一尝试-------------------------------------------------周一经过测试、
[user_name]
[profile文件名]解决方案;password as sysdba2,重新测试没有该问题出现,先记下来;5:1、以dba身份登录sqlplus username&#47: An attempt by a client to checkout a Connection has timed out - 断鸿零雁 - 断鸿零雁的博客 3;
如、 create profile [profile文件名] limit connect_time unlimited idle_time unlimited
来自团队:
其他类似问题
为您推荐:
c3p0的相关知识
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁09:45 提问
使用c3p0连接池是出现了空指针异常
连接不上我的mysql数据库,但是我单独测试又可以连接上,测试代码如下:
Connection conn =
Statement stmt =
ResultSet rs =
Class.forName("com.mysql.jdbc.Driver");
String url = "jdbc:mysql://localhost:3306/shi";
String name = "root";
String password = "root";
conn = DriverManager.getConnection(url, name, password);
String sql = "select * from t_user";
stmt = conn.createStatement();
rs = stmt.executeQuery(sql);
while(rs.next()) {
String username = rs.getString("name");
System.out.println(username);
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
} finally {
if(rs != null) {
rs.close();
} catch (SQLException e) {
e.printStackTrace();
if(stmt != null) {
stmt.close();
} catch (SQLException e) {
e.printStackTrace();
if(rs != null) {
rs.close();
} catch (SQLException e) {
e.printStackTrace();
但是使用c3p0的时候就出问题了:
c3p0的配置如下:
&?xml version="1.0" encoding="UTF-8"?&
&property name="jdbcUrl"&jdbc:mysql://localhost:3306/shi?useUnicode=true&characterEncoding=utf8&/property&
&property name="driverClass"&com.mysql.jdbc.Driver&/property&
&property name="user"&root&/property&
&property name="password"&root&/property&
&property name="jdbcUrl"&jdbc:oracle:thin:@localhost:1521:orcl&/property&
&property name="driverClass"&oracle.jdbc.driver.OracleDriver&/property&
&property name="user"&scott&/property&
&property name="password"&tiger&/property&
&property name="c3p0.testConnectionOnCheckout"&true&/property&
&property name="acquireIncrement"&3&/property&
&property name="initialPoolSize"&10&/property&
&property name="minPoolSize"&2&/property&
&property name="maxPoolSize"&10&/property&
&/default-config&
出现的异常如下:
9:31:05 com.mchange.v2.log.MLog
信息: MLog clients using java 1.4+ standard logging.
9:31:06 com.mchange.v2.c3p0.C3P0Registry
信息: Initializing c3p0-0.9.5-pre8 [built 04-April-:15 -0700; debug? trace: 10]
9:31:06 com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource
信息: Initializing c3p0 pool... com.mchange.boPooledDataSource [ acquireIncrement -& 3, acquireRetryAttempts -& 30, acquireRetryDelay -& 1000, autoCommitOnClose -& false, automaticTestTable -& null, breakAfterAcquireFailure -& false, checkoutTimeout -& 0, connectionCustomizerClassName -& null, connectionTesterClassName -& com.mchange.v2.c3p0.impl.DefaultConnectionTester, contextClassLoaderSource -& caller, dataSourceName -& 2sa1hd931f5tqer1kt6lht|2c766a24, debugUnreturnedConnectionStackTraces -& false, description -& null, driverClass -& null, extensions -& {}, factoryClassLocation -& null, forceIgnoreUnresolvedTransactions -& false, forceUseNamedDriverClass -& false, identityToken -& 2sa1hd931f5tqer1kt6lht|2c766a24, idleConnectionTestPeriod -& 0, initialPoolSize -& 3, jdbcUrl -& null, maxAdministrativeTaskTime -& 0, maxConnectionAge -& 0, maxIdleTime -& 0, maxIdleTimeExcessConnections -& 0, maxPoolSize -& 15, maxStatements -& 0, maxStatementsPerConnection -& 0, minPoolSize -& 3, numHelperThreads -& 3, preferredTestQuery -& null, privilegeSpawnedThreads -& false, properties -& {}, propertyCycle -& 0, statementCacheNumDeferredCloseThreads -& 0, testConnectionOnCheckin -& false, testConnectionOnCheckout -& false, unreturnedConnectionTimeout -& 0, userOverrides -& {}, usesTraditionalReflectiveProxies -& false ]
9:31:36 com.mchange.v2.resourcepool.BasicResourcePool
警告: com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask@6c3b78cf -- 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:
java.lang.NullPointerException
at sun.jdbc.odbc.JdbcOdbcDriver.getProtocol(JdbcOdbcDriver.java:507)
at sun.jdbc.odbc.JdbcOdbcDriver.knownURL(JdbcOdbcDriver.java:476)
at sun.jdbc.odbc.JdbcOdbcDriver.acceptsURL(JdbcOdbcDriver.java:307)
at java.sql.DriverManager.getDriver(DriverManager.java:253)
at com.mchange.v2.c3p0.DriverManagerDataSource.driver(DriverManagerDataSource.java:278)
at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:158)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:161)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:147)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:200)
at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1086)
at com.mchange.v2.resourcepool.BasicResourcePool.doAcquireAndDecrementPendingAcquiresWithinLockOnSuccess(BasicResourcePool.java:1073)
at com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:44)
at com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask.run(BasicResourcePool.java:1814)
at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:696)
9:31:36 com.mchange.v2.resourcepool.BasicResourcePool
警告: Having failed to acquire a resource, com.mchange.v2.resourcepool.BasicResourcePool@5c1fe88d is interrupting all Threads waiting on a resource to check out. Will try again in response to new client requests.
9:31:36 com.mchange.v2.resourcepool.BasicResourcePool
警告: com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask@53416c84 -- 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:
java.lang.NullPointerException
at sun.jdbc.odbc.JdbcOdbcDriver.getProtocol(JdbcOdbcDriver.java:507)
at sun.jdbc.odbc.JdbcOdbcDriver.knownURL(JdbcOdbcDriver.java:476)
at sun.jdbc.odbc.JdbcOdbcDriver.acceptsURL(JdbcOdbcDriver.java:307)
at java.sql.DriverManager.getDriver(DriverManager.java:253)
at com.mchange.v2.c3p0.DriverManagerDataSource.driver(DriverManagerDataSource.java:278)
at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:158)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:161)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:147)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:200)
at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1086)
at com.mchange.v2.resourcepool.BasicResourcePool.doAcquireAndDecrementPendingAcquiresWithinLockOnSuccess(BasicResourcePool.java:1073)
at com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:44)
at com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask.run(BasicResourcePool.java:1814)
at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:696)
java.sql.SQLException: Connections could not be acquired from the underlying database!
at com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.java:118)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:690)
at com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource.getConnection(AbstractPoolBackedDataSource.java:140)
at jdbcUtils.JdbcUtils.getConnection(JdbcUtils.java:44)
at jdbcUtils.TestUtils.main(TestUtils.java:59)
Caused by: com.mchange.v2.resourcepool.CannotAcquireResourceException: A ResourcePool could not acquire a resource from its primary factory or source.
at com.mchange.v2.resourcepool.BasicResourcePool.awaitAvailable(BasicResourcePool.java:1422)
at com.mchange.v2.resourcepool.BasicResourcePool.prelimCheckoutResource(BasicResourcePool.java:606)
at com.mchange.v2.resourcepool.BasicResourcePool.checkoutResource(BasicResourcePool.java:526)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutAndMarkConnectionInUse(C3P0PooledConnectionPool.java:756)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:683)
... 3 more
9:31:36 com.mchange.v2.resourcepool.BasicResourcePool
警告: Having failed to acquire a resource, com.mchange.v2.resourcepool.BasicResourcePool@5c1fe88d is interrupting all Threads waiting on a resource to check out. Will try again in response to new client requests.
9:31:36 com.mchange.v2.resourcepool.BasicResourcePool
警告: com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask@58a2353d -- 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:
java.lang.NullPointerException
at sun.jdbc.odbc.JdbcOdbcDriver.getProtocol(JdbcOdbcDriver.java:507)
at sun.jdbc.odbc.JdbcOdbcDriver.knownURL(JdbcOdbcDriver.java:476)
at sun.jdbc.odbc.JdbcOdbcDriver.acceptsURL(JdbcOdbcDriver.java:307)
at java.sql.DriverManager.getDriver(DriverManager.java:253)
at com.mchange.v2.c3p0.DriverManagerDataSource.driver(DriverManagerDataSource.java:278)
at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:158)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:161)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:147)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:200)
at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1086)
at com.mchange.v2.resourcepool.BasicResourcePool.doAcquireAndDecrementPendingAcquiresWithinLockOnSuccess(BasicResourcePool.java:1073)
at com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:44)
at com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask.run(BasicResourcePool.java:1814)
at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:696)
9:31:36 com.mchange.v2.resourcepool.BasicResourcePool
警告: Having failed to acquire a resource, com.mchange.v2.resourcepool.BasicResourcePool@5c1fe88d is interrupting all Threads waiting on a resource to check out. Will try again in response to new client requests.
按赞数排序
请问这个问题是怎么解决的
其他相似问题
相关参考资料

我要回帖

更多关于 in an attempt to 的文章

 

随机推荐