if (isPoolPreparedStatements()) {
if (getMaxPreparedStatements() <= 0)
{
// since there is no limit, create a prepared statement pool with an eviction thread
// evictor settings are the same as the connection pool settings.
stmtPool = new GenericKeyedObjectPool(null,
getMaxActive(), GenericKeyedObjectPool.WHEN_EXHAUSTED_GROW, 0,
getMaxIdle(), false, false,
getTimeBetweenEvictionRunsMillis(),getNumTestsPerEvictionRun(),getMinEvictableIdleTimeMillis(),
false);
}
else
{
// since there is limit, create a prepared statement pool without an eviction thread
// pool has LRU functionality so when the limit is reached, 15% of the pool is cleared.
// see org.apache.commons.pool.impl.GenericKeyedObjectPool.clearOldest method
stmtPool = new GenericKeyedObjectPool(null,
getMaxActive(), GenericKeyedObjectPool.WHEN_EXHAUSTED_GROW, 0,
getMaxIdle(), getMaxPreparedStatements(), false, false,
-1,0,0, // -1 tells the pool that there should be no eviction thread.
false);
}