1 21 22 package org.apache.derby.impl.jdbc; 23 24 import java.sql.SQLDataException ; 25 import java.sql.SQLException ; 26 import java.sql.SQLIntegrityConstraintViolationException ; 27 import java.sql.SQLInvalidAuthorizationSpecException ; 28 import java.sql.SQLSyntaxErrorException ; 29 import java.sql.SQLTransactionRollbackException ; 30 import java.sql.SQLTransientConnectionException ; 31 import java.sql.SQLFeatureNotSupportedException ; 32 import org.apache.derby.iapi.error.StandardException; 33 import org.apache.derby.shared.common.reference.SQLState; 34 35 39 40 public class SQLExceptionFactory40 extends SQLExceptionFactory { 41 42 61 62 public SQLException getSQLException(String message, String messageId, 63 SQLException next, int severity, Throwable t, Object [] args) { 64 String sqlState = StandardException.getSQLStateFromIdentifier(messageId); 65 66 t = wrapArgsForTransportAcrossDRDA( message, messageId, next, severity, t, args ); 71 72 final SQLException ex; 73 if (sqlState.startsWith(SQLState.CONNECTIVITY_PREFIX)) { 74 ex = new SQLTransientConnectionException (message, sqlState, 77 severity, t); 78 } else if (sqlState.startsWith(SQLState.SQL_DATA_PREFIX)) { 79 ex = new SQLDataException (message, sqlState, severity, t); 80 } else if (sqlState.startsWith(SQLState.INTEGRITY_VIOLATION_PREFIX)) { 81 ex = new SQLIntegrityConstraintViolationException (message, sqlState, 82 severity, t); 83 } else if (sqlState.startsWith(SQLState.AUTHORIZATION_PREFIX)) { 84 ex = new SQLInvalidAuthorizationSpecException (message, sqlState, 85 severity, t); 86 } 87 else if (sqlState.startsWith(SQLState.TRANSACTION_PREFIX)) { 88 ex = new SQLTransactionRollbackException (message, sqlState, 89 severity, t); 90 } else if (sqlState.startsWith(SQLState.LSE_COMPILATION_PREFIX)) { 91 ex = new SQLSyntaxErrorException (message, sqlState, severity, t); 92 } else if (sqlState.startsWith(SQLState.UNSUPPORTED_PREFIX)) { 93 ex = new SQLFeatureNotSupportedException (message, sqlState, severity, t); 94 } else { 95 ex = new SQLException (message, sqlState, severity, t); 96 } 97 98 if (next != null) { 99 ex.setNextException(next); 100 } 101 return ex; 102 } 103 104 112 public SQLException getArgumentFerry(SQLException se) 113 { 114 Throwable cause = se.getCause(); 115 116 if ( (cause == null) || !(cause instanceof EmbedSQLException )) { return se; } 117 else { return (SQLException ) cause; } 118 } 119 120 131 private SQLException wrapArgsForTransportAcrossDRDA 132 ( String message, String messageId, SQLException next, int severity, Throwable t, Object [] args ) 133 { 134 return super.getSQLException( message, messageId, next, severity, t, args ); 135 } 136 137 } 138 | Popular Tags |