All pastes #734452 Raw Edit

Unnamed

public text v1 · immutable
·published 2007-10-12 18:46 UTC
rendered paste body
int connectionPoolSize = (indexThreads * 2) + 1;
ObjectPool connectionPool;
connectionPool = new GenericObjectPool(null,                           // factory                                                                     
                                               connectionPoolSize,                       // maxActive                                                         
                                               GenericObjectPool.WHEN_EXHAUSTED_BLOCK,   // whenExhaustedAction                                               
                                               -1,                                       // maxWait                                                           
                                               connectionPoolSize,                       // maxidle                                                           
                                               1,                                        // minIdle                                                           
                                               true,                                     // testOnBorrow                                                      
                                               false,                                    // testOnReturn                                                      
                                               3600000,                                  // timeBetweenEvictionRunMillis                                      
                                               3,                                        // numTestsPerEvictionRun                                            
                                               1800000,                                  // minEvictableIdleTimeMillis                                        
                                               true);                                    // testWhileIdle                                                                                                                                                                                                                  

ConnectionFactory connectionFactory = new DriverManagerConnectionFactory(jdbcUrl, null);
PoolableConnectionFactory poolableConnectionFactory = new PoolableConnectionFactory(connectionFactory, // connFactory                                 
                                                                                            connectionPool,    // pool                                        
                                                                                            null,              // stmtPoolFactory                             
                                                                                            "select 1",        // validationQuery                             
                                                                                            false,             // defaultReadOnly                             
                                                                                           true);             //defaultAutoCommit                          

DataSource dataSource = new PoolingDataSource(connectionPool);
final Connection c = dataSource.getConnection();