private boolean checkConnection ( ) { if ( connection == null ) { if ( System . currentTimeMillis ( ) >= reconnectTimestamp ) { long start = System . currentTimeMillis ( ) ; try { connection = connect ( url , user , password ) ; statement = connection . prepareStatement ( sql ) ; InternalLogger . log ( Level . ERROR , "Lost log entries due to broken database connection: " + lostCount ) ; lostCount = 0 ; return true ; } catch ( NamingException ex ) { long now = System . currentTimeMillis ( ) ; reconnectTimestamp = now + Math . max ( MIN_RETRY_INTERVAL , ( now - start ) * 2 ) ; closeConnectionSilently ( ) ; return false ; } catch ( SQLException ex ) { long now = System . currentTimeMillis ( ) ; reconnectTimestamp = now + Math . max ( MIN_RETRY_INTERVAL , ( now - start ) * 2 ) ; closeConnectionSilently ( ) ; return false ; } } else { return false ; } } else { return true ; } }
Checks if database connection is opened . Regular attempts are made to reestablish a broken database connection .