public static boolean isConnectionException(SQLException e) throws AdeInternalException {
  boolean isSessionSeverity;
  logger.trace("isConnectionException()  --> entry");
  final String connectionUrl=getDatabaseUrl();
  if (connectionUrl == null) {
    throw new AdeInternalException("isConnectionException() - unknown jdbc driver");
  }
  if (!connectionUrl.contains(DERBY_JDBC_TYPE)) {
    throw new AdeInternalException("isConnectionException() - unsupported jdbc driver: " + connectionUrl);
  }
  final String sqlState=e.getSQLState();
  if (sqlState == null || sqlState.isEmpty()) {
    throw new AdeInternalException("isConnectionException() - unknown sql state");
  }
  isSessionSeverity=sqlState.startsWith(DERBY_SESSION_SEVERITY);
  logger.trace(String.format("isConnectionException()  <-- exit (%b)",isSessionSeverity));
  return isSessionSeverity;
}

public static boolean isConnectionException ( SQLException e ) throws AdeInternalException { boolean isSessionSeverity ; logger . trace ( "isConnectionException()  --> entry" ) ; final String connectionUrl = getDatabaseUrl ( ) ; if ( connectionUrl == null ) { throw new AdeInternalException ( "isConnectionException() - unknown jdbc driver" ) ; } if ( ! connectionUrl . contains ( DERBY_JDBC_TYPE ) ) { throw new AdeInternalException ( "isConnectionException() - unsupported jdbc driver: " + connectionUrl ) ; } final String sqlState = e . getSQLState ( ) ; if ( sqlState == null || sqlState . isEmpty ( ) ) { throw new AdeInternalException ( "isConnectionException() - unknown sql state" ) ; } isSessionSeverity = sqlState . startsWith ( DERBY_SESSION_SEVERITY ) ; logger . trace ( String . format ( "isConnectionException()  <-- exit (%b)" , isSessionSeverity ) ) ; return isSessionSeverity ; }
method to try to determine the broad category ( class ) of sql error the input exception represents , and whether or not that class is connection - oriented . note that most online doc uses terminology oriented towards " session " when describing this class of errors , but we equate this to " connection " . for better or for worse , each database implementation is free to see the world thru its own pair of rose glasses , and so we must ask about the underlying database implementation as we proceed . currently only derby is supported . the derby client returns all errors as sqlexceptions , and offers the getsqlstate ( ) method as a way of accessing the state , which is normally in 5 - digit xxyyy string format ( at least in the cases we care about ) . here xx represents the " broad category " we seek ( yyy represents something specific within that category ) . note that we should like to use constants from : org . apache . derby . shared . common . reference . sqlstate but this package does not appear to be included in the derby jar files that we use . . . ( ? not quite sure why . . . ) , so we make due with constant derby_session_severity above , until such time as we figure out how to properly access the official constants . . .
