Thanks for the informative response!
I downloaded the very newest C3PO, version 0.8.5-pre4 (was using pre2 previously) and added to my project.
I created c3po.properties at the base of my src directory and made sure this directory was in my classpath.
Added the three properties being discussed and set acquireRetryAttempts=1.
Ran my program -- no change. Still seeing thirty connection attempts spaced at one second. After thirty seconds, I get the following console output:
com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@f7c31d -- 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).
The SQLException is caught and logged within hibernate, but not rethrown, so application execution continues despite the failure to obtain a connection. When the first attempt is made to obtain a Connection this process repeats, with another thirty attempts, after which the SQLException is received by the application and it terminates.
I tried stepping through again, but was unable to find the spot in code where the c3po.properties are loaded. What I did find is where a PoolConfig instance is being created and passed to C3PO. This PoolConfig contains properties from the hibernate config file, but not the additional properties from the c3po.properties file.
Code:
public void configure(Properties props) throws
(...)
try {
int minPoolSize = PropertiesHelper.getInt(Environment.C3P0_MIN_SIZE, props, 1);
int maxPoolSize = PropertiesHelper.getInt(Environment.C3P0_MAX_SIZE, props, 100);
int maxIdleTime = PropertiesHelper.getInt(Environment.C3P0_TIMEOUT, props, 0);
int maxStatements = PropertiesHelper.getInt(Environment.C3P0_MAX_STATEMENTS, props, 0);
int acquireIncrement = PropertiesHelper.getInt(Environment.C3P0_ACQUIRE_INCREMENT, props, 1);
int idleTestPeriod = PropertiesHelper.getInt(Environment.C3P0_IDLE_TEST_PERIOD, props, 0);
boolean validateConnection = PropertiesHelper.getBoolean(Environment.C3P0_VALIDATE_CONNECTION, props);
PoolConfig pcfg = new PoolConfig();
pcfg.setInitialPoolSize(minPoolSize);
pcfg.setMinPoolSize(minPoolSize);
pcfg.setMaxPoolSize(maxPoolSize);
pcfg.setAcquireIncrement(acquireIncrement);
pcfg.setMaxIdleTime(maxIdleTime);
pcfg.setMaxStatements(maxStatements);
pcfg.setTestConnectionOnCheckout(validateConnection);
pcfg.setIdleConnectionTestPeriod(idleTestPeriod);
/*DataSource unpooled = DataSources.unpooledDataSource(
jdbcUrl, props.getProperty(Environment.USER), props.getProperty(Environment.PASS)
);*/
DataSource unpooled = DataSources.unpooledDataSource(jdbcUrl, connectionProps);
ds = DataSources.pooledDataSource(unpooled, pcfg);
}
catch (Exception e) {
log.fatal("could not instantiate C3P0 connection pool", e);
throw new HibernateException("Could not instantiate C3P0 connection pool", e);
}
String i = props.getProperty(Environment.ISOLATION);
if (i==null) {
isolation=null;
}
else {
isolation = new Integer(i);
log.info( "JDBC isolation level: " + Environment.isolationLevelToString( isolation.intValue() ) );
}
}
I assume that I have put c3po.properties in the wrong place, but I thought it might be possible that Hibernate is initializing C3PO in such a way that is doesn't bother looking at c3po.properties...
Is it obvious from this post what I'm doing wrong?
Thanks again,
Thom