在Windows Machine中连接到Postgress DB时发生异常

时间:2018-10-18 13:13:40

标签: java postgresql c3p0

在连接到Windows Machine中的postgress DB时获得以下异常。有人可以帮忙吗

使用c3p0-0.9.5.2.jar

例外:

  

2018-09-26 15:53:41,841错误,   com.mchange.v2.resourcepool.BasicResourcePool $ ScatteredAcquireTask.run   ,资源池永久损坏!   [com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask@87274ea]   (因为一系列20次获取尝试均失败。)2018-09-26   15:53:41,841错误,   com.mchange.v2.resourcepool.BasicResourcePool.unexpectedBreak,   com.mchange.v2.resourcepool.BasicResourcePool@735b478-出乎意​​料   坏了!

     

com.mchange.v2.resourcepool.ResourcePoolException:意外中断   堆栈跟踪!在   com.mchange.v2.resourcepool.BasicResourcePool.unexpectedBreak(BasicResourcePool.java:974)   在   com.mchange.v2.resourcepool.BasicResourcePool.access $ 1000(BasicResourcePool.java:44)   在   com.mchange.v2.resourcepool.BasicResourcePool $ ScatteredAcquireTask.run(BasicResourcePool.java:1927)   在   com.mchange.v2.async.ThreadPoolAsynchronousRunner $ PoolThread.run(ThreadPoolAsynchronousRunner.java:696)   java.sql.SQLException:以下情况引发了SQLException   失败:位于以下位置的java.lang.InterruptedException   com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.java:118)在   com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.java:77)在   com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.java:74)在   com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:694)   在   com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource.getConnection(AbstractPoolBackedDataSource.java:146)   由以下原因引起:java.lang.InterruptedException   java.lang.Object.wait(本机方法)在   com.mchange.v2.resourcepool.BasicResourcePool.awaitAvailable(BasicResourcePool.java:1465)   在   com.mchange.v2.resourcepool.BasicResourcePool.prelimCheckoutResource(BasicResourcePool.java:644)   在   com.mchange.v2.resourcepool.BasicResourcePool.checkoutResource(BasicResourcePool.java:554)   在   com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutAndMarkConnectionInUse(C3P0PooledConnectionPool.java:758)   在   com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:685)   ...还有6个

private static ComboPooledDataSource cpds = new ComboPooledDataSource();
try {
cpds = new ComboPooledDataSource();
cpds.setDriverClass(BSMRCommonConstant.POSTGRES_DRIVER);
cpds.setAcquireIncrement(5);
cpds.setBreakAfterAcquireFailure(true);
cpds.setAcquireRetryAttempts(20);
cpds.setMaxPoolSize(20);
cpds.setMaxIdleTime(60 * 10);
cpds.setTestConnectionOnCheckout(true);
cpds.setAcquireRetryDelay(3000);            
cpds.setIdleConnectionTestPeriod(100);          
} catch (PropertyVetoException e) {
e.printStackTrace();
}
Connection con = null;
cpds.setJdbcUrl(url);
cpds.setPassword(password);
cpds.setUser(userName);
con = cpds.getConnection(userName, password); 

1 个答案:

答案 0 :(得分:0)

c3po数据库连接池无法在配置的超时期限内创建数据库连接。

这很可能是配置错误。仔细看看您告诉c3po使用的URL。