Class SQLExceptionFactory

java.lang.Object
org.apache.derby.iapi.jdbc.ExceptionFactory
org.apache.derby.impl.jdbc.SQLExceptionFactory

public class SQLExceptionFactory extends ExceptionFactory
Class to create SQLException
  • Constructor Details

    • SQLExceptionFactory

      public SQLExceptionFactory()
  • Method Details

    • getSQLException

      public SQLException getSQLException(String message, String messageId, SQLException next, int severity, Throwable t, Object... args)

      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
       
      Specified by:
      getSQLException in class ExceptionFactory
      Parameters:
      message - the exception message
      messageId - the message id
      next - the next SQLException
      severity - the severity of the exception
      t - the cause of the exception
      args - the message arguments
      Returns:
      an SQLException
    • getSQLException

      public final SQLException getSQLException(String messageId, SQLException next, Throwable cause, Object... args)
      Construct an SQLException whose message and severity are derived from the message id.
      Specified by:
      getSQLException in class ExceptionFactory
      Parameters:
      messageId - the message id
      next - the next SQLException
      cause - the cause of the exception
      args - the message arguments
      Returns:
      an SQLException
    • wrapArgsForTransportAcrossDRDA

      private StandardException wrapArgsForTransportAcrossDRDA(String messageId, Throwable cause, Object[] args)

      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 StandardException which preserves that information, unless the cause is already a StandardException which contains the necessary information for serializing the exception.