diff --git a/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java b/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java index 5dab736049..3baabdcefe 100644 --- a/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java +++ b/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java @@ -1380,8 +1380,7 @@ private boolean isAuthenticationException (SQLException sqlException) { boolean authFail = false; // get exception which carries Derby messageID and args - SQLException se = Util.getExceptionFactory(). - getArgumentFerry(sqlException); + SQLException se = StandardException.getArgumentFerry(sqlException); if (se instanceof EmbedSQLException) { // DERBY-3060: if this is an EmbedSQLException, we can @@ -6446,7 +6445,7 @@ private String buildSqlerrmc (SQLException se) String sqlerrmc; // get exception which carries Derby messageID and args, per DERBY-1178 - se = Util.getExceptionFactory().getArgumentFerry( se ); + se = StandardException.getArgumentFerry( se ); if (se instanceof EmbedSQLException && ! severe) { sqlerrmc = buildTokenizedSqlerrmc(se); diff --git a/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection.java b/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection.java index ac0b5bc807..7cdd8ff767 100644 --- a/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection.java +++ b/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection.java @@ -47,9 +47,6 @@ public abstract class BrokeredConnection implements EngineConnection protected boolean isClosed; private String connString; - /** Exception factory for the underlying connection. */ - private final ExceptionFactory exceptionFactory; - /** Maintain state as seen by this Connection handle, not the state of the underlying Connection it is attached to. @@ -68,8 +65,6 @@ public BrokeredConnection(BrokeredConnectionControl control) throws SQLException { this.control = control; - this.exceptionFactory = - control.getRealConnection().getExceptionFactory(); } // JDBC 2.0 methods @@ -505,7 +500,7 @@ public final PreparedStatement prepareStatement( * @return a no-current-connection exception */ final SQLException noCurrentConnection() { - return exceptionFactory.getSQLException( + return ExceptionFactory.getInstance().getSQLException( SQLState.NO_CURRENT_CONNECTION, null, null, null); } @@ -773,13 +768,6 @@ public void resetFromPool() getRealConnection().resetFromPool(); } - /** - * Return the exception factory for the underlying connection. - */ - public final ExceptionFactory getExceptionFactory() { - return exceptionFactory; - } - //////////////////////////////////////////////////////////////////// // // INTRODUCED BY JDBC 4.1 IN JAVA 7 diff --git a/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection40.java b/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection40.java index c39ee43c95..e277e4087a 100644 --- a/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection40.java +++ b/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection40.java @@ -320,7 +320,7 @@ public final T unwrap(java.lang.Class interfaces) try { return interfaces.cast(this); } catch (ClassCastException cce) { - throw getExceptionFactory().getSQLException( + throw ExceptionFactory.getInstance().getSQLException( SQLState.UNABLE_TO_UNWRAP, null, null, new Object[]{ interfaces }); } diff --git a/java/engine/org/apache/derby/iapi/jdbc/BrokeredStatement.java b/java/engine/org/apache/derby/iapi/jdbc/BrokeredStatement.java index 63d41de05a..a226a993cd 100644 --- a/java/engine/org/apache/derby/iapi/jdbc/BrokeredStatement.java +++ b/java/engine/org/apache/derby/iapi/jdbc/BrokeredStatement.java @@ -582,7 +582,7 @@ protected final void checkIfClosed() throws SQLException { if (isClosed()) { - throw control.getExceptionFactory().getSQLException( + throw ExceptionFactory.getInstance().getSQLException( SQLState.ALREADY_CLOSED, null, null, new Object[]{ "Statement" }); } @@ -596,7 +596,7 @@ protected final void checkIfClosed() * @return an exception indicating that unwrap failed */ final SQLException unableToUnwrap(Class iface) { - return control.getExceptionFactory().getSQLException( + return ExceptionFactory.getInstance().getSQLException( SQLState.UNABLE_TO_UNWRAP, null, null, new Object[]{ iface }); } diff --git a/java/engine/org/apache/derby/iapi/jdbc/BrokeredStatementControl.java b/java/engine/org/apache/derby/iapi/jdbc/BrokeredStatementControl.java index c20c46e3b0..80388ba67f 100644 --- a/java/engine/org/apache/derby/iapi/jdbc/BrokeredStatementControl.java +++ b/java/engine/org/apache/derby/iapi/jdbc/BrokeredStatementControl.java @@ -80,10 +80,4 @@ public interface BrokeredStatementControl @param s Statement that created the ResultSet. */ public ResultSet wrapResultSet(Statement s, ResultSet rs); - - /** - * Return the exception factory for the underlying connection. - * @return an exception factory instance - */ - public ExceptionFactory getExceptionFactory(); } diff --git a/java/engine/org/apache/derby/iapi/jdbc/EngineConnection.java b/java/engine/org/apache/derby/iapi/jdbc/EngineConnection.java index 2336135eef..482d3266c5 100644 --- a/java/engine/org/apache/derby/iapi/jdbc/EngineConnection.java +++ b/java/engine/org/apache/derby/iapi/jdbc/EngineConnection.java @@ -21,7 +21,6 @@ Licensed to the Apache Software Foundation (ASF) under one or more package org.apache.derby.iapi.jdbc; import java.sql.Connection; -import java.sql.PreparedStatement; import java.sql.SQLException; import java.sql.SQLWarning; @@ -110,14 +109,6 @@ public void addWarning(SQLWarning newWarning) */ public void resetFromPool() throws SQLException; - /** - * Return an exception factory that could be used to generate - * {@code SQLException}s raised by this connection. - * - * @return an exception factory instance - */ - public ExceptionFactory getExceptionFactory(); - //////////////////////////////////////////////////////////////////// // // INTRODUCED BY JDBC 4.1 IN JAVA 7 diff --git a/java/engine/org/apache/derby/iapi/jdbc/ExceptionFactory.java b/java/engine/org/apache/derby/iapi/jdbc/ExceptionFactory.java index 21cc2cd09e..7165bb6929 100644 --- a/java/engine/org/apache/derby/iapi/jdbc/ExceptionFactory.java +++ b/java/engine/org/apache/derby/iapi/jdbc/ExceptionFactory.java @@ -26,20 +26,35 @@ Licensed to the Apache Software Foundation (ASF) under one or more /** * An exception factory is used to create SQLExceptions of the correct type. */ -public interface ExceptionFactory { +public abstract class ExceptionFactory { + + /** The singleton ExceptionFactory instance. */ + private static final ExceptionFactory INSTANCE; + static { + // Initialize the singleton instance. Use reflection so that there + // is no compile-time dependency on implementation classes from iapi. + // Currently, there is only one implementation. There used to be two; + // one for JDBC 3.0 and lower, and one for JDBC 4.0 and higher. If + // the need for more than one implementation ever arises again, the + // code below should be changed to load the correct factory for the + // run-time platform. + String impl = "org.apache.derby.impl.jdbc.SQLExceptionFactory"; + ExceptionFactory factory = null; + try { + factory = (ExceptionFactory) Class.forName(impl).newInstance(); + } catch (Exception e) { + throw new ExceptionInInitializerError(e); + } + INSTANCE = factory; + } /** - * Unpack a SQL exception, looking for an EmbedSQLException which carries - * the Derby messageID and args which we will serialize across DRDA so - * that the client can reconstitute a SQLException with appropriate text. - * If we are running JDBC 3, then we hope that the passed-in - * exception is already an EmbedSQLException, which carries all the - * information we need. - * - * @param se the exception to unpack - * @return the argument ferry for the exception + * Get the singleton exception factory instance. + * @return an {@code ExceptionFactory} instance */ - SQLException getArgumentFerry(SQLException se); + public static ExceptionFactory getInstance() { + return INSTANCE; + } /** * Construct an SQLException whose message and severity are specified @@ -53,8 +68,8 @@ public interface ExceptionFactory { * @param args the message arguments * @return an SQLException */ - SQLException getSQLException(String message, String messageId, - SQLException next, int severity, Throwable cause, Object[] args); + public abstract SQLException getSQLException(String message, String messageId, + SQLException next, int severity, Throwable cause, Object... args); /** * Construct an SQLException whose message and severity are derived from @@ -66,7 +81,6 @@ SQLException getSQLException(String message, String messageId, * @param args the message arguments * @return an SQLException */ - SQLException getSQLException(String messageId, SQLException next, - Throwable cause, Object[] args); - + public abstract SQLException getSQLException(String messageId, + SQLException next, Throwable cause, Object... args); } diff --git a/java/engine/org/apache/derby/impl/jdbc/EmbedConnection.java b/java/engine/org/apache/derby/impl/jdbc/EmbedConnection.java index b1e2ba14f7..c196cc9a81 100644 --- a/java/engine/org/apache/derby/impl/jdbc/EmbedConnection.java +++ b/java/engine/org/apache/derby/impl/jdbc/EmbedConnection.java @@ -88,7 +88,6 @@ Licensed to the Apache Software Foundation (ASF) under one or more import java.util.concurrent.Executor; import org.apache.derby.iapi.jdbc.EngineLOB; -import org.apache.derby.iapi.jdbc.ExceptionFactory; import org.apache.derby.iapi.jdbc.FailedProperties40; import org.apache.derby.iapi.reference.Limits; import org.apache.derby.iapi.sql.conn.StatementContext; @@ -3184,11 +3183,6 @@ final int getResultSetOrderId() { } } - /** Get the exception factory for this connection. */ - public ExceptionFactory getExceptionFactory() { - return Util.getExceptionFactory(); - } - protected static SQLException newSQLException(String messageId) { return Util.generateCsSQLException(messageId); } diff --git a/java/engine/org/apache/derby/impl/jdbc/SQLExceptionFactory.java b/java/engine/org/apache/derby/impl/jdbc/SQLExceptionFactory.java index 16832d29cd..c342013d0f 100644 --- a/java/engine/org/apache/derby/impl/jdbc/SQLExceptionFactory.java +++ b/java/engine/org/apache/derby/impl/jdbc/SQLExceptionFactory.java @@ -21,50 +21,124 @@ Licensed to the Apache Software Foundation (ASF) under one or more package org.apache.derby.impl.jdbc; +import java.sql.SQLDataException; +import java.sql.SQLException; +import java.sql.SQLFeatureNotSupportedException; +import java.sql.SQLIntegrityConstraintViolationException; +import java.sql.SQLInvalidAuthorizationSpecException; +import java.sql.SQLNonTransientConnectionException; +import java.sql.SQLSyntaxErrorException; +import java.sql.SQLTimeoutException; +import java.sql.SQLTransactionRollbackException; import org.apache.derby.iapi.error.StandardException; import org.apache.derby.iapi.jdbc.ExceptionFactory; import org.apache.derby.iapi.services.i18n.MessageService; - -import java.sql.SQLException; +import org.apache.derby.shared.common.reference.SQLState; /** *Class to create SQLException * */ -public class SQLExceptionFactory implements ExceptionFactory { +public class SQLExceptionFactory extends ExceptionFactory { /** + *

* method to construct SQLException * version specific drivers can overload this method to create * version specific exceptions + *

+ * + *

+ * This implementation creates JDBC 4 exceptions. + *

+ * + *
+     * SQLSTATE CLASS (prefix)     Exception
+     * 0A                          java.sql.SQLFeatureNotSupportedException
+     * 08                          java.sql.SQLNonTransientConnectionException
+     * 22                          java.sql.SQLDataException
+     * 28                          java.sql.SQLInvalidAuthorizationSpecException
+     * 40                          java.sql.SQLTransactionRollbackException
+     * 42                          java.sql.SQLSyntaxErrorException
+     * 
*/ + @Override public SQLException getSQLException(String message, String messageId, - SQLException next, int severity, Throwable t, Object[] args) { - return new EmbedSQLException(message, messageId, next, severity, - t, args); + SQLException next, int severity, Throwable t, Object... args) { + String sqlState = StandardException.getSQLStateFromIdentifier(messageId); + + // + // Create dummy exception which ferries arguments needed to serialize + // SQLExceptions across the DRDA network layer. + // + t = wrapArgsForTransportAcrossDRDA( message, messageId, next, severity, t, args ); + + final SQLException ex; + if (sqlState.startsWith(SQLState.CONNECTIVITY_PREFIX)) { + //no derby sqlstate belongs to + //TransientConnectionException DERBY-3074 + ex = new SQLNonTransientConnectionException(message, sqlState, severity, t); + } else if (sqlState.startsWith(SQLState.SQL_DATA_PREFIX)) { + ex = new SQLDataException(message, sqlState, severity, t); + } else if (sqlState.startsWith(SQLState.INTEGRITY_VIOLATION_PREFIX)) { + ex = new SQLIntegrityConstraintViolationException(message, sqlState, + severity, t); + } else if (sqlState.startsWith(SQLState.AUTHORIZATION_SPEC_PREFIX)) { + ex = new SQLInvalidAuthorizationSpecException(message, sqlState, + severity, t); + } + else if (sqlState.startsWith(SQLState.TRANSACTION_PREFIX)) { + ex = new SQLTransactionRollbackException(message, sqlState, + severity, t); + } 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); + } 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, severity, t); + } else { + ex = new SQLException(message, sqlState, severity, t); + } + + if (next != null) { + ex.setNextException(next); + } + return ex; } /** * Construct an SQLException whose message and severity are derived from * the message id. */ + @Override public final SQLException getSQLException(String messageId, - SQLException next, Throwable cause, Object[] args) { + SQLException next, Throwable cause, Object... args) { String message = MessageService.getCompleteMessage(messageId, args); int severity = StandardException.getSeverityFromIdentifier(messageId); return getSQLException(message, messageId, next, severity, cause, args); } /** - * Unpack a SQL exception, looking for an EmbedSQLException which carries - * the Derby messageID and args which we will serialize across DRDA so - * that the client can reconstitute a SQLException with appropriate text. - * If we are running JDBC3 or JDBC2, then we hope that the passed-in - * exception is already an EmbedSQLException, which carries all the - * information we need. + *

+ * The following method helps handle DERBY-1178. The problem is that we may + * need to serialize our final SQLException across the DRDA network layer. + * That serialization involves some clever encoding of the Derby messageID and + * arguments. Unfortunately, once we create one of the + * JDBC4-specific subclasses of SQLException, we lose the messageID and + * args. This method creates a dummy EmbedSQLException which preserves that + * information. We return the dummy exception. + *

*/ - public SQLException getArgumentFerry(SQLException se) - { - return StandardException.getArgumentFerry(se); - } - + private SQLException wrapArgsForTransportAcrossDRDA( + String message, String messageId, SQLException next, + int severity, Throwable t, Object[] args) { + return new EmbedSQLException( + message, messageId, + (next == null ? + null : StandardException.getArgumentFerry(next)), + severity, t, args); + } } diff --git a/java/engine/org/apache/derby/impl/jdbc/SQLExceptionFactory40.java b/java/engine/org/apache/derby/impl/jdbc/SQLExceptionFactory40.java deleted file mode 100644 index 97bb22cce5..0000000000 --- a/java/engine/org/apache/derby/impl/jdbc/SQLExceptionFactory40.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - - Derby - Class org.apache.derby.impl.jdbc.SQLExceptionFactory40 - - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to you under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - */ - -package org.apache.derby.impl.jdbc; - -import java.sql.SQLDataException; -import java.sql.SQLException; -import java.sql.SQLIntegrityConstraintViolationException; -import java.sql.SQLInvalidAuthorizationSpecException; -import java.sql.SQLNonTransientConnectionException; -import java.sql.SQLSyntaxErrorException; -import java.sql.SQLTimeoutException; -import java.sql.SQLTransactionRollbackException; -import java.sql.SQLFeatureNotSupportedException; -import org.apache.derby.iapi.error.StandardException; -import org.apache.derby.shared.common.reference.SQLState; - -/** - * SQLExceptionFactory40 overwrites getSQLException method - * to return SQLException or one of its sub class - */ - -public class SQLExceptionFactory40 extends SQLExceptionFactory { - - /** - * overwrites super class method to create JDBC4 exceptions - * SQLSTATE CLASS (prefix) Exception - * 0A java.sql.SQLFeatureNotSupportedException - * 08 java.sql.SQLNonTransientConnectionException - * 22 java.sql.SQLDataException - * 28 java.sql.SQLInvalidAuthorizationSpecException - * 40 java.sql.SQLTransactionRollbackException - * 42 java.sql.SQLSyntaxErrorException - * - * Note the following divergence from JDBC3 behavior: When running - * a JDBC3 client, we return EmbedSQLException. That exception class - * overrides Throwable.toString() and strips off the Throwable's class name. - * In contrast, the following JDBC4 implementation returns - * subclasses of java.sql.Exception. These subclasses inherit the behavior - * of Throwable.toString(). That is, their toString() output includes - * their class name. This will break code which relies on the - * stripping behavior of EmbedSQLSxception.toString(). - */ - - public SQLException getSQLException(String message, String messageId, - SQLException next, int severity, Throwable t, Object[] args) { - String sqlState = StandardException.getSQLStateFromIdentifier(messageId); - - // - // Create dummy exception which ferries arguments needed to serialize - // SQLExceptions across the DRDA network layer. - // - t = wrapArgsForTransportAcrossDRDA( message, messageId, next, severity, t, args ); - - final SQLException ex; - if (sqlState.startsWith(SQLState.CONNECTIVITY_PREFIX)) { - //no derby sqlstate belongs to - //TransientConnectionException DERBY-3074 - ex = new SQLNonTransientConnectionException(message, sqlState, severity, t); - } else if (sqlState.startsWith(SQLState.SQL_DATA_PREFIX)) { - ex = new SQLDataException(message, sqlState, severity, t); - } else if (sqlState.startsWith(SQLState.INTEGRITY_VIOLATION_PREFIX)) { - ex = new SQLIntegrityConstraintViolationException(message, sqlState, - severity, t); - } else if (sqlState.startsWith(SQLState.AUTHORIZATION_SPEC_PREFIX)) { - ex = new SQLInvalidAuthorizationSpecException(message, sqlState, - severity, t); - } - else if (sqlState.startsWith(SQLState.TRANSACTION_PREFIX)) { - ex = new SQLTransactionRollbackException(message, sqlState, - severity, t); - } 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); - } 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, severity, t); - } else { - ex = new SQLException(message, sqlState, severity, t); - } - - if (next != null) { - ex.setNextException(next); - } - return ex; - } - - /** - *

- * The following method helps handle DERBY-1178. The problem is that we may - * need to serialize our final SQLException across the DRDA network layer. - * That serialization involves some clever encoding of the Derby messageID and - * arguments. Unfortunately, once we create one of the - * JDBC4-specific subclasses of SQLException, we lose the messageID and - * args. This method creates a dummy EmbedSQLException which preserves that - * information. We return the dummy exception. - *

- */ - private SQLException wrapArgsForTransportAcrossDRDA - ( String message, String messageId, SQLException next, int severity, Throwable t, Object[] args ) - { - // Generate an EmbedSQLException - SQLException e = - super.getSQLException(message, messageId, - (next == null ? null : getArgumentFerry(next)), - severity, t, args); - return e; - } - -} diff --git a/java/engine/org/apache/derby/impl/jdbc/Util.java b/java/engine/org/apache/derby/impl/jdbc/Util.java index 30ad125d5e..9e52cff12a 100644 --- a/java/engine/org/apache/derby/impl/jdbc/Util.java +++ b/java/engine/org/apache/derby/impl/jdbc/Util.java @@ -23,6 +23,7 @@ Licensed to the Apache Software Foundation (ASF) under one or more import org.apache.derby.iapi.error.ErrorStringBuilder; import org.apache.derby.iapi.error.StandardException; +import org.apache.derby.iapi.jdbc.ExceptionFactory; import org.apache.derby.iapi.services.i18n.MessageService; import org.apache.derby.iapi.services.info.JVMInfo; @@ -70,11 +71,6 @@ Licensed to the Apache Software Foundation (ASF) under one or more //the actual changes made. public abstract class Util { - - private static SQLExceptionFactory exceptionFactory = - new SQLExceptionFactory (); - - private static int logSeverityLevel = PropertyUtil.getSystemInt(Property.LOG_SEVERITY_LEVEL, SanityManager.DEBUG ? 0 : ExceptionSeverity.SESSION_SEVERITY); /* @@ -143,7 +139,7 @@ private static SQLException newEmbedSQLException(String messageId, Object[] args, SQLException next, int severity, Throwable t) { String message = MessageService.getCompleteMessage (messageId, args); - return exceptionFactory.getSQLException ( + return ExceptionFactory.getInstance().getSQLException( message, messageId, next, severity, t, args); } @@ -279,41 +275,13 @@ private static boolean isSupportedType(int dataType) ** they don't directly do a new Util. */ - /* 3 arguments */ - static SQLException newException(String messageID, Object a1, - Object a2, Object a3) { - return newEmbedSQLException(messageID, new Object[] {a1, a2, a3}, - StandardException.getSeverityFromIdentifier(messageID)); - } - - - public static SQLException generateCsSQLException(String error) { + public static SQLException generateCsSQLException( + String error, Object... args) { return newEmbedSQLException(error, + args, StandardException.getSeverityFromIdentifier(error)); } - public static SQLException generateCsSQLException(String error, Object arg1) { - return newEmbedSQLException(error, - new Object[] {arg1}, - StandardException.getSeverityFromIdentifier(error)); - } - - public static SQLException generateCsSQLException( - String error, Object arg1, Object arg2){ - return newEmbedSQLException(error, - new Object[] {arg1, arg2}, - StandardException.getSeverityFromIdentifier(error)); - } - - public static SQLException generateCsSQLException( - String error, Object arg1, Object arg2, Object arg3) { - - return newEmbedSQLException(error, - new Object[] {arg1, arg2, arg3}, - StandardException.getSeverityFromIdentifier(error)); - } - - static SQLException generateCsSQLException( String error, Object arg1, Throwable t) { return newEmbedSQLException(error, @@ -322,7 +290,7 @@ static SQLException generateCsSQLException( } public static SQLException generateCsSQLException(StandardException se) { - return exceptionFactory.getSQLException( + return ExceptionFactory.getInstance().getSQLException( se.getMessage(), se.getMessageId(), (SQLException) null, se.getSeverity(), se, se.getArguments()); } @@ -453,26 +421,9 @@ public static int[] squashLongs( long[] longs ) * @return an {@code IOException} linked to {@code cause} */ static IOException newIOException(Throwable cause) { - IOException ioe = new IOException(cause.getMessage()); - ioe.initCause(cause); - return ioe; + return new IOException(cause); } - /** - * this method is called to replace the exception factory to be - * used to generate the SQLException or the subclass - */ - - public static void setExceptionFactory (SQLExceptionFactory factory) { - exceptionFactory = factory; - } - - /** - * Get the exception factory specific to the version of JDBC which - * we are running. - */ - public static SQLExceptionFactory getExceptionFactory() { return exceptionFactory; } - public static String typeName(int jdbcType) { switch (jdbcType) { case Types.ARRAY: return TypeId.ARRAY_NAME; diff --git a/java/engine/org/apache/derby/jdbc/AutoloadedDriver40.java b/java/engine/org/apache/derby/jdbc/AutoloadedDriver40.java index bb77363b68..73b9cc5ccb 100644 --- a/java/engine/org/apache/derby/jdbc/AutoloadedDriver40.java +++ b/java/engine/org/apache/derby/jdbc/AutoloadedDriver40.java @@ -24,7 +24,6 @@ Licensed to the Apache Software Foundation (ASF) under one or more import java.sql.SQLFeatureNotSupportedException; import java.util.logging.Logger; -import org.apache.derby.impl.jdbc.SQLExceptionFactory40; import org.apache.derby.impl.jdbc.Util; /** @@ -35,7 +34,6 @@ public class AutoloadedDriver40 extends AutoloadedDriver static { registerMe( new AutoloadedDriver40() ); - Util.setExceptionFactory (new SQLExceptionFactory40 ()); } //////////////////////////////////////////////////////////////////// diff --git a/java/engine/org/apache/derby/jdbc/Driver40.java b/java/engine/org/apache/derby/jdbc/Driver40.java index 78ee32fae7..d714546f33 100644 --- a/java/engine/org/apache/derby/jdbc/Driver40.java +++ b/java/engine/org/apache/derby/jdbc/Driver40.java @@ -26,7 +26,6 @@ Licensed to the Apache Software Foundation (ASF) under one or more import org.apache.derby.iapi.jdbc.BrokeredConnectionControl; import org.apache.derby.iapi.jdbc.BrokeredConnection40; import org.apache.derby.iapi.sql.ResultSet; -import org.apache.derby.iapi.error.StandardException; import org.apache.derby.impl.jdbc.EmbedCallableStatement; import org.apache.derby.impl.jdbc.EmbedConnection; import org.apache.derby.impl.jdbc.EmbedConnection40; @@ -35,7 +34,6 @@ Licensed to the Apache Software Foundation (ASF) under one or more import org.apache.derby.impl.jdbc.EmbedResultSet40; import org.apache.derby.impl.jdbc.EmbedStatement; import org.apache.derby.impl.jdbc.EmbedDatabaseMetaData40; -import org.apache.derby.impl.jdbc.SQLExceptionFactory40; import org.apache.derby.impl.jdbc.EmbedResultSetMetaData40; import org.apache.derby.iapi.jdbc.ResourceAdapter; import org.apache.derby.impl.jdbc.Util; @@ -134,17 +132,6 @@ public EmbedResultSet newEmbedResultSet(EmbedConnection conn, ResultSet results, isAtomic); } - /** - * Overwriting the super class boot method to set exception factory - * @see InternalDriver#boot - */ - - public void boot(boolean create, Properties properties) - throws StandardException { - Util.setExceptionFactory (new SQLExceptionFactory40 ()); - super.boot (create, properties); - } - public DatabaseMetaData newEmbedDatabaseMetaData(EmbedConnection conn, String dbname) throws SQLException { return new EmbedDatabaseMetaData40(conn,dbname); diff --git a/java/engine/org/apache/derby/jdbc/XAStatementControl.java b/java/engine/org/apache/derby/jdbc/XAStatementControl.java index c665cb4472..7be6e578a5 100644 --- a/java/engine/org/apache/derby/jdbc/XAStatementControl.java +++ b/java/engine/org/apache/derby/jdbc/XAStatementControl.java @@ -26,7 +26,6 @@ Licensed to the Apache Software Foundation (ASF) under one or more import org.apache.derby.iapi.jdbc.BrokeredStatement; import org.apache.derby.iapi.jdbc.BrokeredPreparedStatement; import org.apache.derby.iapi.jdbc.BrokeredCallableStatement; -import org.apache.derby.iapi.jdbc.ExceptionFactory; import org.apache.derby.impl.jdbc.EmbedConnection; import org.apache.derby.impl.jdbc.EmbedResultSet; import org.apache.derby.impl.jdbc.EmbedStatement; @@ -241,11 +240,4 @@ public ResultSet wrapResultSet(Statement s, ResultSet rs) { public int checkHoldCursors(int holdability) throws SQLException { return xaConnection.checkHoldCursors(holdability, true); } - - /** - * Return the exception factory for the underlying connection. - */ - public ExceptionFactory getExceptionFactory() { - return applicationConnection.getExceptionFactory(); - } } diff --git a/tools/jar/extraDBMSclasses.properties b/tools/jar/extraDBMSclasses.properties index 722e7a077d..20937a9fee 100644 --- a/tools/jar/extraDBMSclasses.properties +++ b/tools/jar/extraDBMSclasses.properties @@ -30,6 +30,7 @@ derby.module.aggs.SumAvgAggDef=org.apache.derby.impl.sql.execute.UserDefinedAggr derby.module.jndi.basicSchemaBase=org.apache.derby.impl.jdbc.authentication.JNDIAuthenticationSchemeBase derby.module.jndi.basicService=org.apache.derby.impl.jdbc.authentication.JNDIAuthenticationService derby.module.jndi.LDAPSchemeImpl=org.apache.derby.impl.jdbc.authentication.LDAPAuthenticationSchemeImpl +derby.module.jdbc.exception=org.apache.derby.impl.jdbc.SQLExceptionFactory derby.module.vti.locktable=org.apache.derby.diag.LockTable derby.module.vti.metadata.template=org.apache.derby.vti.VTIMetaDataTemplate