Return-Path: Delivered-To: apmail-db-derby-commits-archive@www.apache.org Received: (qmail 95846 invoked from network); 25 Mar 2006 16:08:03 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 25 Mar 2006 16:08:03 -0000 Received: (qmail 37000 invoked by uid 500); 25 Mar 2006 16:08:03 -0000 Delivered-To: apmail-db-derby-commits-archive@db.apache.org Received: (qmail 36934 invoked by uid 500); 25 Mar 2006 16:08:02 -0000 Mailing-List: contact derby-commits-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: "Derby Development" List-Id: Delivered-To: mailing list derby-commits@db.apache.org Received: (qmail 36923 invoked by uid 99); 25 Mar 2006 16:08:02 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 25 Mar 2006 08:08:02 -0800 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Sat, 25 Mar 2006 08:08:01 -0800 Received: (qmail 95771 invoked by uid 65534); 25 Mar 2006 16:07:41 -0000 Message-ID: <20060325160741.95770.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r388778 - in /db/derby/code/trunk/java: client/org/apache/derby/client/am/SQLExceptionFactory40.java engine/org/apache/derby/impl/jdbc/SQLExceptionFactory40.java shared/org/apache/derby/shared/common/reference/SQLState.java Date: Sat, 25 Mar 2006 16:07:40 -0000 To: derby-commits@db.apache.org From: rhillegas@apache.org X-Mailer: svnmailer-1.0.7 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: rhillegas Date: Sat Mar 25 08:07:40 2006 New Revision: 388778 URL: http://svn.apache.org/viewcvs?rev=388778&view=rev Log: Commit my patch, attached to DERBY-1140, which eliminates magic strings in the JDBC4 SQLException factories. Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/SQLExceptionFactory40.java db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/SQLExceptionFactory40.java db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/SQLState.java Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/SQLExceptionFactory40.java URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/client/org/apache/derby/client/am/SQLExceptionFactory40.java?rev=388778&r1=388777&r2=388778&view=diff ============================================================================== --- db/derby/code/trunk/java/client/org/apache/derby/client/am/SQLExceptionFactory40.java (original) +++ db/derby/code/trunk/java/client/org/apache/derby/client/am/SQLExceptionFactory40.java Sat Mar 25 08:07:40 2006 @@ -19,6 +19,8 @@ */ package org.apache.derby.client.am; +import org.apache.derby.shared.common.reference.SQLState; + import java.sql.SQLDataException; import java.sql.SQLException; import java.sql.SQLFeatureNotSupportedException; @@ -54,24 +56,24 @@ SQLException ex = null; if (sqlState == null) { ex = new SQLException(message, sqlState, errCode); - } else if (sqlState.startsWith("08")) { + } else if (sqlState.startsWith(SQLState.CONNECTIVITY_PREFIX)) { //none of the sqlstate supported by derby belongs to //NonTransientConnectionException ex = new SQLTransientConnectionException(message, sqlState, errCode); - } else if (sqlState.startsWith("22")) { + } else if (sqlState.startsWith(SQLState.SQL_DATA_PREFIX)) { ex = new SQLDataException(message, sqlState, errCode); - } else if (sqlState.startsWith("23")) { + } else if (sqlState.startsWith(SQLState.INTEGRITY_VIOLATION_PREFIX)) { ex = new SQLIntegrityConstraintViolationException(message, sqlState, errCode); - } else if (sqlState.startsWith("28")) { + } else if (sqlState.startsWith(SQLState.AUTHORIZATION_PREFIX)) { ex = new SQLInvalidAuthorizationSpecException(message, sqlState, errCode); - } else if (sqlState.startsWith("40")) { + } else if (sqlState.startsWith(SQLState.TRANSACTION_PREFIX)) { ex = new SQLTransactionRollbackException(message, sqlState, errCode); - } else if (sqlState.startsWith("42")) { + } else if (sqlState.startsWith(SQLState.LSE_COMPILATION_PREFIX)) { ex = new SQLSyntaxErrorException(message, sqlState, errCode); - } else if (sqlState.startsWith ("0A")) { + } else if (sqlState.startsWith (SQLState.UNSUPPORTED_PREFIX)) { ex = new SQLFeatureNotSupportedException(message, sqlState, errCode); } else { Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/SQLExceptionFactory40.java URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/SQLExceptionFactory40.java?rev=388778&r1=388777&r2=388778&view=diff ============================================================================== --- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/SQLExceptionFactory40.java (original) +++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/SQLExceptionFactory40.java Sat Mar 25 08:07:40 2006 @@ -27,7 +27,9 @@ import java.sql.SQLSyntaxErrorException; import java.sql.SQLTransactionRollbackException; import java.sql.SQLTransientConnectionException; +import java.sql.SQLFeatureNotSupportedException; import org.apache.derby.iapi.error.StandardException; +import org.apache.derby.shared.common.reference.SQLState; /** * SQLExceptionFactory40 overwrites getSQLException method @@ -39,6 +41,7 @@ /** * overwrites super class method to create JDBC4 exceptions * SQLSTATE CLASS (prefix) Exception + * 0A java.sql.SQLFeatureNotSupportedException * 08 java.sql.SQLTransientConnectionException * 22 java.sql.SQLDataException * 28 java.sql.SQLInvalidAuthorizationSpecException @@ -61,25 +64,27 @@ SQLException next, int severity, Throwable t, Object[] args) { String sqlState = StandardException.getSQLStateFromIdentifier(messageId); SQLException ex = new SQLException(message, sqlState, severity, t); - if (sqlState.startsWith("08")) { + if (sqlState.startsWith(SQLState.CONNECTIVITY_PREFIX)) { //none of the sqlstate supported by derby belongs to //NonTransientConnectionException ex = new SQLTransientConnectionException(message, sqlState, severity, t); - } else if (sqlState.startsWith("22")) { + } else if (sqlState.startsWith(SQLState.SQL_DATA_PREFIX)) { ex = new SQLDataException(message, sqlState, severity, t); - } else if (sqlState.startsWith("23")) { + } else if (sqlState.startsWith(SQLState.INTEGRITY_VIOLATION_PREFIX)) { ex = new SQLIntegrityConstraintViolationException(message, sqlState, severity, t); - } else if (sqlState.startsWith("28")) { + } else if (sqlState.startsWith(SQLState.AUTHORIZATION_PREFIX)) { ex = new SQLInvalidAuthorizationSpecException(message, sqlState, severity, t); } - else if (sqlState.startsWith("40")) { + else if (sqlState.startsWith(SQLState.TRANSACTION_PREFIX)) { ex = new SQLTransactionRollbackException(message, sqlState, severity, t); - } else if (sqlState.startsWith("42")) { + } else if (sqlState.startsWith(SQLState.LSE_COMPILATION_PREFIX)) { ex = new SQLSyntaxErrorException(message, sqlState, severity, t); + } else if (sqlState.startsWith(SQLState.UNSUPPORTED_PREFIX)) { + ex = new SQLFeatureNotSupportedException(message, sqlState, severity, t); } if (next != null) { Modified: db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/SQLState.java URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/SQLState.java?rev=388778&r1=388777&r2=388778&view=diff ============================================================================== --- db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/SQLState.java (original) +++ db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/SQLState.java Sat Mar 25 08:07:40 2006 @@ -427,6 +427,8 @@ /* ** RawStore - Transactions.Basic transaction exceptions */ + String TRANSACTION_PREFIX="40"; + String XACT_PROTOCOL_VIOLATION = "40XT0"; String XACT_COMMIT_EXCEPTION = "40XT1"; String XACT_ROLLBACK_EXCEPTION = "40XT2"; @@ -562,6 +564,7 @@ /* ** Connectivity - Connection Exceptions: 08XXX */ + String CONNECTIVITY_PREFIX="08"; String ERROR_CLOSE = "08003"; @@ -664,6 +667,11 @@ // 40XC0 - 40XCZ String LANG_DEAD_STATEMENT = "40XC0"; + /* + ** SQL Data exceptions + */ + String SQL_DATA_PREFIX="22"; + String LANG_MISSING_PARMS = "07000"; String LANG_SCALAR_SUBQUERY_CARDINALITY_VIOLATION = "21000"; String LANG_STRING_TRUNCATION = "22001"; @@ -686,6 +694,13 @@ String LANG_INVALID_ESCAPE_SEQUENCE = "22025"; String LANG_INVALID_TRIM_SET = "22027"; String LANG_ESCAPE_IS_NULL = "22501"; + + + /* + ** Integrity violations. + */ + String INTEGRITY_VIOLATION_PREFIX="23"; + String LANG_NULL_INTO_NON_NULL = "23502"; String LANG_DUPLICATE_KEY_CONSTRAINT = "23505"; String LANG_FK_VIOLATION = "23503"; @@ -1338,6 +1353,8 @@ /* SQL standard 0A - feature not supported */ + String UNSUPPORTED_PREFIX="0A"; + String NOT_IMPLEMENTED = "0A000.S"; String JDBC_METHOD_NOT_IMPLEMENTED = "0AX01.S"; @@ -1346,6 +1363,8 @@ /* ** Authorization and Authentication */ + String AUTHORIZATION_PREFIX="28"; + String AUTH_DATABASE_CONNECTION_REFUSED = "04501.C"; String AUTH_SET_CONNECTION_READ_ONLY_IN_ACTIVE_XACT = "25501"; String AUTH_WRITE_WITH_READ_ONLY_CONNECTION = "25502";