Reputation: 43
I have set BreakAfterAcquireFailure to true, MaxIdleTime and MaxConnectionAge's value are 10 (very small).Like below:
ComboPooledDataSource ds = new ComboPooledDataSource(db);
ds.setAcquireRetryAttempts(3);
ds.setBreakAfterAcquireFailure(true);
ds.setMaxIdleTime(10);
ds.setMaxConnectionAge(10);
ds.setMaxPoolSize(2);
ds.setMinPoolSize(1);
ds.setTestConnectionOnCheckin(false);
ds.setIdleConnectionTestPeriod(10);
ds.setPreferredTestQuery("select 1");
Why ComboPooledDataSource.getConnection() always throw exception, after restarting the mysql for a long time.
Who can help me? Thanks a lot.
Upvotes: 0
Views: 1894
Reputation: 14073
breakAfterAcquireFailure
means precisely that c3p0 will not try to recover from a dbms outage. if breakAfterAcquireFailure
is set, the DataSource eill simply mark itself broken if it finds it cannot acquire new Connections, and never try again. if you want your DataSource to recover from an outtage, leave that parameter at its default value of false
.
You don't want such small values for maxIdleTime
and maxConnectionAge
. That's terrible. If you are relying upon idle Connection tests, it's a good idea to also set testConnectionOnCheckin
to true
. 10 seconds is probably more aggressive than you need for idleConnectionTestPeriod
. Given your pool size params, I presume you are just testing / playing with this, though. (maxPoolSize
of 2 is way too small for most uses.)
Upvotes: 4