public static boolean isUsableConnection(Connection C){
  boolean open=false, valid=false;
  final int timeoutSeconds=MAX_CONNECTION_PROBE_TIME;
  logger.trace("isUsableConnection() -->entry");
  if (C == null) {
    logger.error("isUsableConnection() <-- exit (No Connection)");
    return false;
  }
  try {
    open=!C.isClosed();
  }
 catch (  Throwable t) {
    surfaceThrowable("isUsableConnection called Connection.isClosed()",t);
  }
  try {
    valid=C.isValid(timeoutSeconds);
  }
 catch (  Throwable t) {
    surfaceThrowable("isUsableConnection called isValid()",t);
  }
  logger.trace(String.format("isUsableConnection() <-- exit (Connection is open: %b, is valid: %b)",open,valid));
  return open && valid;
}

public static boolean isUsableConnection ( Connection C ) { boolean open = false , valid = false ; final int timeoutSeconds = MAX_CONNECTION_PROBE_TIME ; logger . trace ( "isUsableConnection() -->entry" ) ; if ( C == null ) { logger . error ( "isUsableConnection() <-- exit (No Connection)" ) ; return false ; } try { open = ! C . isClosed ( ) ; } catch ( Throwable t ) { surfaceThrowable ( "isUsableConnection called Connection.isClosed()" , t ) ; } try { valid = C . isValid ( timeoutSeconds ) ; } catch ( Throwable t ) { surfaceThrowable ( "isUsableConnection called isValid()" , t ) ; } logger . trace ( String . format ( "isUsableConnection() <-- exit (Connection is open: %b, is valid: %b)" , open , valid ) ) ; return open && valid ; }
method to deal with the set of connectivity issues introduced by our penchant for restarting derby independent of other processes . the connection . isvalid ( ) method takes a timeout value in units = = seconds , which apparently gives us control over how patient we wish to be ( as it probes ? ) . we have chosen an arbitrary value for this .
