private synchronized PoolableConnection newConnection ( ) { synchronized ( xpool ) { if ( xpool . size ( ) >= maxActive ) { return null ; } try { PoolableConnection conn = null ; if ( xpool . size ( ) < minIdle ) { conn = new PoolableConnection ( this , ds . getConnection ( ) , liveTime , Integer . MAX_VALUE , maxOpenPreparedStatementsPerConnection ) ; } else if ( xpool . size ( ) < maxIdle ) { conn = new PoolableConnection ( this , ds . getConnection ( ) , liveTime , maxIdleTime , maxOpenPreparedStatementsPerConnection ) ; } else { conn = new PoolableConnection ( this , ds . getConnection ( ) , liveTime , 60 * 1000L , maxOpenPreparedStatementsPerConnection ) ; } xpool . put ( conn , conn ) ; if ( logger . isWarnEnabled ( ) ) { logger . warn ( "The " + xpool . size ( ) + "th of " + maxActive + " connections is created for data source: " + url ) ; } return conn ; } catch ( SQLException e ) { String msg = "Faied to create new connection for data source '" + url + "'." + " [Active connection number]: " + ( xpool . size ( ) + 1 ) + ". " + AbacusException . getErrorMsg ( e ) ; logger . error ( msg , e ) ; throw new UncheckedSQLException ( msg , e ) ; } } }
Method newConnection .