You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by ka...@apache.org on 2013/06/17 12:00:31 UTC

svn commit: r1493701 - in /db/derby/code/trunk: java/drda/org/apache/derby/impl/drda/ java/engine/org/apache/derby/iapi/jdbc/ java/engine/org/apache/derby/impl/jdbc/ java/engine/org/apache/derby/jdbc/ tools/jar/

Author: kahatlen
Date: Mon Jun 17 10:00:30 2013
New Revision: 1493701

URL: http://svn.apache.org/r1493701
Log:
DERBY-6253: Collapse SQLException factories

- Move functionality from SQLExceptionFactory40 to SQLExceptionFactory

- Move logic for retrieving the exception factory from Util to
  ExceptionFactory in order to reduce compile-time dependencies on
  impl classes from iapi classes

- Use varargs in Util's helper methods in order to reduce the number
  of methods

Removed:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/SQLExceptionFactory40.java
Modified:
    db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection40.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredStatement.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredStatementControl.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/EngineConnection.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/ExceptionFactory.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/SQLExceptionFactory.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/Util.java
    db/derby/code/trunk/java/engine/org/apache/derby/jdbc/AutoloadedDriver40.java
    db/derby/code/trunk/java/engine/org/apache/derby/jdbc/Driver40.java
    db/derby/code/trunk/java/engine/org/apache/derby/jdbc/XAStatementControl.java
    db/derby/code/trunk/tools/jar/extraDBMSclasses.properties

Modified: db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java?rev=1493701&r1=1493700&r2=1493701&view=diff
==============================================================================
--- db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java (original)
+++ db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java Mon Jun 17 10:00:30 2013
@@ -1380,8 +1380,7 @@ class DRDAConnThread extends Thread {
         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 @@ class DRDAConnThread extends Thread {
         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);

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection.java?rev=1493701&r1=1493700&r2=1493701&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection.java Mon Jun 17 10:00:30 2013
@@ -47,9 +47,6 @@ public abstract class BrokeredConnection
 	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 abstract class BrokeredConnection
             throws SQLException
 	{
 		this.control = control;
-        this.exceptionFactory =
-                control.getRealConnection().getExceptionFactory();
 	}
 
     // JDBC 2.0 methods
@@ -505,7 +500,7 @@ public abstract class BrokeredConnection
      * @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 abstract class BrokeredConnection
         getRealConnection().resetFromPool();
     }
 
-    /**
-     * Return the exception factory for the underlying connection.
-     */
-    public final ExceptionFactory getExceptionFactory() {
-        return exceptionFactory;
-    }
-    
     ////////////////////////////////////////////////////////////////////
     //
     // INTRODUCED BY JDBC 4.1 IN JAVA 7

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection40.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection40.java?rev=1493701&r1=1493700&r2=1493701&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection40.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection40.java Mon Jun 17 10:00:30 2013
@@ -320,7 +320,7 @@ public class BrokeredConnection40
             try {
                 return interfaces.cast(this);
             } catch (ClassCastException cce) {
-                throw getExceptionFactory().getSQLException(
+                throw ExceptionFactory.getInstance().getSQLException(
                         SQLState.UNABLE_TO_UNWRAP, null, null,
                         new Object[]{ interfaces });
             }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredStatement.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredStatement.java?rev=1493701&r1=1493700&r2=1493701&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredStatement.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredStatement.java Mon Jun 17 10:00:30 2013
@@ -582,7 +582,7 @@ public abstract class BrokeredStatement 
         throws SQLException
     {
         if (isClosed()) {
-            throw control.getExceptionFactory().getSQLException(
+            throw ExceptionFactory.getInstance().getSQLException(
                     SQLState.ALREADY_CLOSED, null, null,
                     new Object[]{ "Statement" });
         }
@@ -596,7 +596,7 @@ public abstract class BrokeredStatement 
      * @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 });
     }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredStatementControl.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredStatementControl.java?rev=1493701&r1=1493700&r2=1493701&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredStatementControl.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredStatementControl.java Mon Jun 17 10:00:30 2013
@@ -80,10 +80,4 @@ public interface BrokeredStatementContro
         @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();
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/EngineConnection.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/EngineConnection.java?rev=1493701&r1=1493700&r2=1493701&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/EngineConnection.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/EngineConnection.java Mon Jun 17 10:00:30 2013
@@ -21,7 +21,6 @@
 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 interface EngineConnection extend
      */
     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

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/ExceptionFactory.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/ExceptionFactory.java?rev=1493701&r1=1493700&r2=1493701&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/ExceptionFactory.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/ExceptionFactory.java Mon Jun 17 10:00:30 2013
@@ -26,20 +26,35 @@ import java.sql.SQLException;
 /**
  * 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 @@ public interface ExceptionFactory {
      * @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);
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection.java?rev=1493701&r1=1493700&r2=1493701&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection.java Mon Jun 17 10:00:30 2013
@@ -88,7 +88,6 @@ import java.util.Iterator;
 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 @@ public abstract class EmbedConnection im
 		}
 	}
 
-    /** Get the exception factory for this connection. */
-    public ExceptionFactory getExceptionFactory() {
-        return Util.getExceptionFactory();
-    }
-
 	protected static SQLException newSQLException(String messageId) {
 		return Util.generateCsSQLException(messageId);
 	}

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/SQLExceptionFactory.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/SQLExceptionFactory.java?rev=1493701&r1=1493700&r2=1493701&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/SQLExceptionFactory.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/SQLExceptionFactory.java Mon Jun 17 10:00:30 2013
@@ -21,50 +21,124 @@
 
 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 {
     /**
+     * <p>
      * method to construct SQLException
      * version specific drivers can overload this method to create
      * version specific exceptions
+     * </p>
+     *
+     * <p>
+     * This implementation creates JDBC 4 exceptions.
+     * </p>
+     *
+     * <pre>
+     * 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
+     * </pre>
      */
+    @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.
+     * <p>
+     * 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.
+     * </p>
 	 */
-	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);
+    }
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/Util.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/Util.java?rev=1493701&r1=1493700&r2=1493701&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/Util.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/Util.java Mon Jun 17 10:00:30 2013
@@ -23,6 +23,7 @@ package org.apache.derby.impl.jdbc;
 
 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 @@ import java.io.IOException;
 //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 @@ public abstract class Util  {
 			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 @@ public abstract class Util  {
 	** 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 @@ public abstract class Util  {
 	}
 
 	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 abstract class Util  {
      * @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;

Modified: db/derby/code/trunk/java/engine/org/apache/derby/jdbc/AutoloadedDriver40.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/jdbc/AutoloadedDriver40.java?rev=1493701&r1=1493700&r2=1493701&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/jdbc/AutoloadedDriver40.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/jdbc/AutoloadedDriver40.java Mon Jun 17 10:00:30 2013
@@ -24,7 +24,6 @@ package org.apache.derby.jdbc;
 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 
 	static
 	{
         registerMe( new AutoloadedDriver40() );
-        Util.setExceptionFactory (new SQLExceptionFactory40 ());
 	}
 
     ////////////////////////////////////////////////////////////////////

Modified: db/derby/code/trunk/java/engine/org/apache/derby/jdbc/Driver40.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/jdbc/Driver40.java?rev=1493701&r1=1493700&r2=1493701&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/jdbc/Driver40.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/jdbc/Driver40.java Mon Jun 17 10:00:30 2013
@@ -26,7 +26,6 @@ import org.apache.derby.iapi.jdbc.Broker
 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 @@ import org.apache.derby.impl.jdbc.EmbedR
 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 class Driver40 extends Driver30 {
             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);

Modified: db/derby/code/trunk/java/engine/org/apache/derby/jdbc/XAStatementControl.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/jdbc/XAStatementControl.java?rev=1493701&r1=1493700&r2=1493701&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/jdbc/XAStatementControl.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/jdbc/XAStatementControl.java Mon Jun 17 10:00:30 2013
@@ -26,7 +26,6 @@ import org.apache.derby.iapi.jdbc.Broker
 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 @@ final class XAStatementControl implement
 	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();
-    }
 }

Modified: db/derby/code/trunk/tools/jar/extraDBMSclasses.properties
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/tools/jar/extraDBMSclasses.properties?rev=1493701&r1=1493700&r2=1493701&view=diff
==============================================================================
--- db/derby/code/trunk/tools/jar/extraDBMSclasses.properties (original)
+++ db/derby/code/trunk/tools/jar/extraDBMSclasses.properties Mon Jun 17 10:00:30 2013
@@ -30,6 +30,7 @@ derby.module.aggs.SumAvgAggDef=org.apach
 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