1 21 package org.apache.derby.client.am; 22 23 import org.apache.derby.shared.common.reference.SQLState; 24 import org.apache.derby.shared.common.error.ExceptionSeverity; 25 26 import java.sql.SQLDataException ; 27 import java.sql.SQLException ; 28 import java.sql.SQLFeatureNotSupportedException ; 29 import java.sql.SQLIntegrityConstraintViolationException ; 30 import java.sql.SQLInvalidAuthorizationSpecException ; 31 import java.sql.SQLSyntaxErrorException ; 32 import java.sql.SQLTransactionRollbackException ; 33 import java.sql.SQLTransientConnectionException ; 34 35 38 39 public class SQLExceptionFactory40 extends SQLExceptionFactory { 40 41 private static final String DRDA_CONVERSATION_TERMINATED = "58009"; 45 private static final String DRDA_COMMAND_NOT_SUPPORTED = "58014"; 46 private static final String DRDA_OBJECT_NOT_SUPPORTED = "58015"; 47 private static final String DRDA_PARAM_NOT_SUPPORTED = "58016"; 48 private static final String DRDA_VALUE_NOT_SUPPORTED = "58017"; 49 private static final String DRDA_SQLTYPE_NOT_SUPPORTED = "56084"; 50 private static final String DRDA_CONVERSION_NOT_SUPPORTED = "57017"; 51 private static final String DRDA_REPLY_MSG_NOT_SUPPORTED = "58018"; 52 53 60 public SQLException getSQLException (String message, String sqlState, 61 int errCode) { 62 SQLException ex = null; 63 if (sqlState == null) { 64 ex = new SQLException (message, sqlState, errCode); 65 } else if (sqlState.startsWith(SQLState.CONNECTIVITY_PREFIX) || 66 errCode >= ExceptionSeverity.SESSION_SEVERITY) { 67 ex = new SQLTransientConnectionException (message, sqlState, errCode); 70 } else if (sqlState.startsWith(SQLState.SQL_DATA_PREFIX)) { 71 ex = new SQLDataException (message, sqlState, errCode); 72 } else if (sqlState.startsWith(SQLState.INTEGRITY_VIOLATION_PREFIX)) { 73 ex = new SQLIntegrityConstraintViolationException (message, sqlState, 74 errCode); 75 } else if (sqlState.startsWith(SQLState.AUTHORIZATION_PREFIX)) { 76 ex = new SQLInvalidAuthorizationSpecException (message, sqlState, 77 errCode); 78 } else if (sqlState.startsWith(SQLState.TRANSACTION_PREFIX) || 79 errCode >= ExceptionSeverity.TRANSACTION_SEVERITY ) { 80 ex = new SQLTransactionRollbackException (message, sqlState, 81 errCode); 82 } else if (sqlState.startsWith(SQLState.LSE_COMPILATION_PREFIX)) { 83 ex = new SQLSyntaxErrorException (message, sqlState, errCode); 84 } else if ( 85 sqlState.startsWith (SQLState.UNSUPPORTED_PREFIX) || 86 sqlState.equals(DRDA_COMMAND_NOT_SUPPORTED) || 87 sqlState.equals(DRDA_OBJECT_NOT_SUPPORTED) || 88 sqlState.equals(DRDA_PARAM_NOT_SUPPORTED) || 89 sqlState.equals(DRDA_VALUE_NOT_SUPPORTED) || 90 sqlState.equals(DRDA_SQLTYPE_NOT_SUPPORTED) || 91 sqlState.equals(DRDA_REPLY_MSG_NOT_SUPPORTED) ) { 92 ex = new SQLFeatureNotSupportedException (message, sqlState, 93 errCode); 94 } else { 95 ex = new SQLException (message, sqlState, errCode); 96 } 97 return ex; 98 } 99 } 100 | Popular Tags |