public DataConnection getConnection ( ) { DataConnection connection ; for ( connection = availableConnections . poll ( ) ; connection != null && ! connection . isUsable ( ) ; connection = availableConnections . poll ( ) ) { if ( ! connection . isUsable ( ) ) { connection . close ( ) ; } } if ( connection == null ) { connection = new DataConnection ( getDataUri ( ) ) ; try { connection . connect ( ) ; } catch ( Exception e ) { logger . error ( "[getConnection] could not connect to database" , e ) ; return null ; } } connection . setLocale ( threadLocale . getLocale ( ) ) ; return connection ; }
Gets a connection from the pool of available and free data connections to this server .