/**
  * Attempt to establish a database connection.
  *
  * @param username name to be used for the connection
  * @param pass password to be used fur the connection
  */
 public PooledConnection getPooledConnection(String username, String pass) throws SQLException {
   getConnectionCalled = true;
   /*
   public GenericKeyedObjectPool(KeyedPoolableObjectFactory factory,
   int maxActive, byte whenExhaustedAction, long maxWait,
   int maxIdle, boolean testOnBorrow, boolean testOnReturn,
   long timeBetweenEvictionRunsMillis,
   int numTestsPerEvictionRun, long minEvictableIdleTimeMillis,
   boolean testWhileIdle) {
   */
   KeyedObjectPool stmtPool = null;
   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);
     }
   }
   // Workaround for buggy WebLogic 5.1 classloader - ignore the
   // exception upon first invocation.
   try {
     PooledConnectionImpl pci = null;
     if (connectionProperties != null) {
       connectionProperties.put("user", username);
       connectionProperties.put("password", pass);
       pci =
           new PooledConnectionImpl(
               DriverManager.getConnection(getUrl(), connectionProperties), stmtPool);
     } else {
       pci =
           new PooledConnectionImpl(
               DriverManager.getConnection(getUrl(), username, pass), stmtPool);
     }
     pci.setAccessToUnderlyingConnectionAllowed(isAccessToUnderlyingConnectionAllowed());
     return pci;
   } catch (ClassCircularityError e) {
     PooledConnectionImpl pci = null;
     if (connectionProperties != null) {
       pci =
           new PooledConnectionImpl(
               DriverManager.getConnection(getUrl(), connectionProperties), stmtPool);
     } else {
       pci =
           new PooledConnectionImpl(
               DriverManager.getConnection(getUrl(), username, pass), stmtPool);
     }
     pci.setAccessToUnderlyingConnectionAllowed(isAccessToUnderlyingConnectionAllowed());
     return pci;
   }
 }