com.pivotal.gemfirexd.internal.client.am

## Class SqlException

- java.lang.Object
- - java.lang.Throwable
  - - java.lang.Exception
    - - com.pivotal.gemfirexd.internal.client.am.SqlException

All Implemented Interfaces:
  Diagnosable, Serializable

Direct Known Subclasses:
  DisconnectException, SqlWarning

    public class SqlException
    extends Exception
    implements Diagnosable

See Also:
  Serialized Form

### Field Summary

Fields
`protected Object[]` `args_`
`static String` `BATCH_POSITION_ID`
`protected String` `cachedMessage_`
`static String` `CAUSED_BY_EXCEPTION_ID`
`protected String` `causeString_`
`static String` `CLIENT_MESSAGE_RESOURCE_NAME`
`protected static int` `DEFAULT_ERRCODE`
`protected int` `errorcode_`
`protected String` `message_`
`protected String` `msgid_`
`protected SqlException` `nextException_`
`protected Sqlca` `sqlca_`
`protected String` `sqlstate_`
`protected Throwable` `throwable_`
`protected SQLException` `wrappedException_` The wrapped SQLException, if one exists

### Constructor Summary

Constructors
`` `SqlException(LogWriter logwriter, ClientMessageId msgid)`
`` `SqlException(LogWriter logwriter, ClientMessageId msgid, Object arg1)`
`` `SqlException(LogWriter logwriter, ClientMessageId msgid, Object[] args)`
`` `SqlException(LogWriter logWriter, ClientMessageId msgid, Object[] args, SqlCode sqlcode)`
`` `SqlException(LogWriter logWriter, ClientMessageId msgid, Object[] args, SqlCode sqlcode, Throwable t)`
`` `SqlException(LogWriter logwriter, ClientMessageId msgid, Object[] args, Throwable cause)` Create a SqlException.
`` `SqlException(LogWriter logwriter, ClientMessageId msgid, Object arg1, Object arg2)`
`` `SqlException(LogWriter logwriter, ClientMessageId msgid, Object arg1, Object arg2, Object arg3)`
`` `SqlException(LogWriter logwriter, ClientMessageId msgid, Object arg1, Object arg2, Object arg3, Throwable cause)`
`` `SqlException(LogWriter logWriter, ClientMessageId msgid, Object arg1, Object arg2, SqlCode sqlcode)`
`` `SqlException(LogWriter logwriter, ClientMessageId msgid, Object arg1, Object arg2, Throwable cause)`
`` `SqlException(LogWriter logWriter, ClientMessageId msgid, Object arg1, SqlCode sqlcode)`
`` `SqlException(LogWriter logwriter, ClientMessageId msgid, Object arg1, Throwable cause)`
`` `SqlException(LogWriter logWriter, ClientMessageId msgid, SqlCode sqlcode)`
`` `SqlException(LogWriter logwriter, ClientMessageId msgid, Throwable cause)`
`` `SqlException(LogWriter logWriter, Sqlca sqlca)` Create an exception for an engine generated error.
`protected` `SqlException(LogWriter logWriter, String reason, String sqlState, int errorCode)`
`protected` `SqlException(LogWriter logWriter, Throwable throwable, String reason, String sqlState, int errorCode, String msgid, Object[] args)`
`` `SqlException(SQLException wrapme)` Wrap a SQLException in a SqlException.

### Method Summary

Methods
`int` `getErrorCode()`
`String` `getMessage()`
`static com.pivotal.gemfirexd.internal.shared.common.i18n.MessageUtil` `getMessageUtil()` This routine provides singleton access to an instance of MessageUtil that is constructed for client messages.
`SqlException` `getNextException()`
`Sqlca` `getSqlca()`
`SQLException` `getSQLException(Agent agent)` Convert this SqlException into a java.sql.SQLException
`SQLException` `getSQLException(Agent agent, String columnName)`
`String` `getSQLState()`
`static SqlException` `javaException(LogWriter logWriter, Throwable e)` Helper method to construct an exception which basically says that we encountered an underlying Java exception
`void` `printTrace(PrintWriter printWriter, String header)`
`void` `setNextException(SqlException nextException)`
`void` `setNextException(SQLException nextException)`
`String` `toString()` Similar to StandardException.toString().

### Methods inherited from class java.lang.Throwable

`addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Field Detail

#### DEFAULT_ERRCODE

    protected static final int DEFAULT_ERRCODE

See Also:
  Constant Field Values

#### sqlca_

    protected transient Sqlca sqlca_

#### message_

    protected String message_

#### cachedMessage_

    protected String cachedMessage_

#### sqlstate_

    protected String sqlstate_

#### errorcode_

    protected int errorcode_

#### causeString_

    protected String causeString_

#### nextException_

    protected SqlException nextException_

#### throwable_

    protected Throwable throwable_

#### msgid_

    protected String msgid_

#### args_

    protected Object[] args_

#### CLIENT_MESSAGE_RESOURCE_NAME

    public static String CLIENT_MESSAGE_RESOURCE_NAME

#### CAUSED_BY_EXCEPTION_ID

    public static final String CAUSED_BY_EXCEPTION_ID

See Also:
  Constant Field Values

#### BATCH_POSITION_ID

    public static final String BATCH_POSITION_ID

See Also:
  Constant Field Values

#### wrappedException_

    protected SQLException wrappedException_

The wrapped SQLException, if one exists

### Constructor Detail

#### SqlException

    public SqlException(LogWriter logwriter,
                ClientMessageId msgid,
                Object[] args,
                Throwable cause)

Create a SqlException. This constructor is the "base" constructor; all other constructors (which take a ClientMessageId) delegate to this constructor

Parameters:
  `logwriter` - Can be null, but if provided, it is used to log this exception
  `msgid` - The message id for this message. ClientMessageId is a simple type-safe wrapper for com.pivotal.gemfirexd.internal.shared.common.reference.SQLState message id strings.
  `args` - The set of substitution arguments for the message. The Java message formatter will substitute these arguments into the internationalized strings using the substitution ({0}, {1}, etc.) markers in the string. Any object can be passed, but if you want it to be readable, make sure toString() for the object returns something useful.
  `cause` - Can be null. Indicates the cause of this exception. If this is an instance of SqlException or java.sql.SQLException then the exception is chained into the nextException chain. Otherwise it is chained using initCause(). On JDK 1.3, since initCause() does not exist, a non-SQL exception can not be chained. Instead, the exception class and message text is appended to the message for this exception.

#### SqlException

    public SqlException(LogWriter logWriter,
                ClientMessageId msgid,
                Object[] args,
                SqlCode sqlcode,
                Throwable t)

#### SqlException

    public SqlException(LogWriter logWriter,
                ClientMessageId msgid,
                Object[] args,
                SqlCode sqlcode)

#### SqlException

    public SqlException(LogWriter logWriter,
                ClientMessageId msgid,
                SqlCode sqlcode)

#### SqlException

    public SqlException(LogWriter logWriter,
                ClientMessageId msgid,
                Object arg1,
                SqlCode sqlcode)

#### SqlException

    public SqlException(LogWriter logWriter,
                ClientMessageId msgid,
                Object arg1,
                Object arg2,
                SqlCode sqlcode)

#### SqlException

    public SqlException(LogWriter logwriter,
                ClientMessageId msgid,
                Throwable cause)

#### SqlException

    public SqlException(LogWriter logwriter,
                ClientMessageId msgid,
                Object[] args)

#### SqlException

    public SqlException(LogWriter logwriter,
                ClientMessageId msgid)

#### SqlException

    public SqlException(LogWriter logwriter,
                ClientMessageId msgid,
                Object arg1)

#### SqlException

    public SqlException(LogWriter logwriter,
                ClientMessageId msgid,
                Object arg1,
                Throwable cause)

#### SqlException

    public SqlException(LogWriter logwriter,
                ClientMessageId msgid,
                Object arg1,
                Object arg2,
                Throwable cause)

#### SqlException

    public SqlException(LogWriter logwriter,
                ClientMessageId msgid,
                Object arg1,
                Object arg2)

#### SqlException

    public SqlException(LogWriter logwriter,
                ClientMessageId msgid,
                Object arg1,
                Object arg2,
                Object arg3)

#### SqlException

    public SqlException(LogWriter logWriter,
                Sqlca sqlca)

Create an exception for an engine generated error.

Parameters:
  `logWriter` - object used for tracing
  `sqlca` - the SQLCA sent from the server

#### SqlException

    protected SqlException(LogWriter logWriter,
                String reason,
                String sqlState,
                int errorCode)

#### SqlException

    protected SqlException(LogWriter logWriter,
                Throwable throwable,
                String reason,
                String sqlState,
                int errorCode,
                String msgid,
                Object[] args)

#### SqlException

    public SqlException(SQLException wrapme)

Wrap a SQLException in a SqlException. This is used by internal routines so the don't have to throw SQLException, which, through the chain of dependencies would force more and more internal routines to throw SQLException

#### SqlException

    public SqlException(LogWriter logwriter,
                ClientMessageId msgid,
                Object arg1,
                Object arg2,
                Object arg3,
                Throwable cause)

### Method Detail

#### getMessageUtil

    public static com.pivotal.gemfirexd.internal.shared.common.i18n.MessageUtil getMessageUtil()

This routine provides singleton access to an instance of MessageUtil that is constructed for client messages. It is recommended to use this singleton rather than create your own instance. The only time you need this instance is if you need to directly format an internationalized message string. In most instances this is done for you when you invoke a SqlException constructor

Returns:
  a singleton instance of MessageUtil configured for client messages

#### getSQLException

    public SQLException getSQLException(Agent agent)

Convert this SqlException into a java.sql.SQLException

#### getSQLException

    public SQLException getSQLException(Agent agent,
                               String columnName)

#### getSqlca

    public Sqlca getSqlca()

Specified by:
  `getSqlca` in interface `Diagnosable`

#### getMessage

    public String getMessage()

Overrides:
  `getMessage` in class `Throwable`

#### getSQLState

    public String getSQLState()

#### getErrorCode

    public int getErrorCode()

#### getNextException

    public SqlException getNextException()

#### setNextException

    public void setNextException(SqlException nextException)

#### setNextException

    public void setNextException(SQLException nextException)

#### printTrace

    public void printTrace(PrintWriter printWriter,
                  String header)

Specified by:
  `printTrace` in interface `Diagnosable`

#### javaException

    public static SqlException javaException(LogWriter logWriter,
                             Throwable e)

Helper method to construct an exception which basically says that we encountered an underlying Java exception

#### toString

    public String toString()

Similar to StandardException.toString(). Don't print the class name in the toString() method for generic case.

Overrides:
  `toString` in class `Throwable`