if (sqlState == null) {
ex = new SQLException(message, sqlState, errCode);
} else if (sqlState.startsWith(SQLState.CONNECTIVITY_PREFIX)) {
//none of the sqlstate supported by derby belongs to
//TransientConnectionException. DERBY-3075
ex = new SQLNonTransientConnectionException(message, sqlState, errCode);
} else if (sqlState.startsWith(SQLState.SQL_DATA_PREFIX)) {
ex = new SQLDataException(message, sqlState, errCode);
} else if (sqlState.startsWith(SQLState.INTEGRITY_VIOLATION_PREFIX)) {
ex = new SQLIntegrityConstraintViolationException(message, sqlState,
errCode);
} else if (sqlState.startsWith(SQLState.AUTHORIZATION_SPEC_PREFIX)) {
ex = new SQLInvalidAuthorizationSpecException(message, sqlState,
errCode);
} else if (sqlState.startsWith(SQLState.TRANSACTION_PREFIX)) {
ex = new SQLTransactionRollbackException(message, sqlState,
errCode);
} else if (sqlState.startsWith(SQLState.LSE_COMPILATION_PREFIX)) {
ex = new SQLSyntaxErrorException(message, sqlState, errCode);
} else if (
sqlState.startsWith (SQLState.UNSUPPORTED_PREFIX) ||
sqlState.equals(DRDA_COMMAND_NOT_SUPPORTED) ||
sqlState.equals(DRDA_OBJECT_NOT_SUPPORTED) ||
sqlState.equals(DRDA_PARAM_NOT_SUPPORTED) ||
sqlState.equals(DRDA_VALUE_NOT_SUPPORTED) ||
sqlState.equals(DRDA_SQLTYPE_NOT_SUPPORTED) ||
sqlState.equals(DRDA_REPLY_MSG_NOT_SUPPORTED) ) {
ex = new SQLFeatureNotSupportedException(message, sqlState,
errCode);
} else if
(
sqlState.equals(SQLState.LANG_STATEMENT_CANCELLED_OR_TIMED_OUT.substring(0, 5)) ||
sqlState.equals(SQLState.LOGIN_TIMEOUT.substring(0, 5))
) {
ex = new SQLTimeoutException(message, sqlState, errCode);
}
// If the sub-class cannot be determined based on the SQLState, use
// the severity instead.
else if (errCode >= ExceptionSeverity.SESSION_SEVERITY) {
ex = new SQLNonTransientConnectionException(
message, sqlState, errCode);
} else if (errCode >= ExceptionSeverity.TRANSACTION_SEVERITY) {
ex = new SQLTransactionRollbackException(
message, sqlState, errCode);
}