Package org.apache.derby.client.am
Class SqlException
- java.lang.Object
-
- java.lang.Throwable
-
- java.lang.Exception
-
- org.apache.derby.client.am.SqlException
-
- All Implemented Interfaces:
java.io.Serializable,Diagnosable
- Direct Known Subclasses:
ColumnTypeConversionException,DisconnectException,OutsideRangeForDataTypeException,SqlWarning
public class SqlException extends java.lang.Exception implements Diagnosable
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.StringbatchPositionLabel_private java.lang.StringcachedMessage_private java.lang.StringcauseString_static java.lang.StringCLIENT_MESSAGE_RESOURCE_NAMEprivate static intDEFAULT_ERRCODEprivate interrorcode_private static SQLExceptionFactoryexceptionFactorySQLException factory is initialized with default factory.private java.lang.Stringmessage_private intmessageNumber_Tells which of the messages in the SQLCA this exception refers to (counting from 0).private static MessageUtilmsgutil_The message utility instance we use to find messages It's primed with the name of the client message bundle so that it knows to look there if the message isn't found in the shared message bundle.protected SqlExceptionnextException_private Sqlcasqlca_private java.lang.Stringsqlstate_protected java.sql.SQLExceptionwrappedException_The wrapped SQLException, if one exists
-
Constructor Summary
Constructors Modifier Constructor Description SqlException(java.sql.SQLException wrapme)Wrap a SQLException in a SqlException.privateSqlException(LogWriter logWriter, java.lang.String reason, java.lang.String sqlState, int errorCode)privateSqlException(LogWriter logWriter, java.lang.Throwable throwable, java.lang.String reason, java.lang.String sqlState, int errorCode)SqlException(LogWriter logwriter, ClientMessageId msgid, java.lang.Object... args)(package private)SqlException(LogWriter logwriter, ClientMessageId msgid, java.lang.Object[] args, java.lang.Throwable cause)Create a SqlException.(package private)SqlException(LogWriter logWriter, ClientMessageId msgid, java.lang.Object[] args, SqlCode sqlcode, java.lang.Throwable t)SqlException(LogWriter logWriter, ClientMessageId msgid, java.lang.Throwable cause, java.lang.Object... args)SqlException(LogWriter logWriter, ClientMessageId msgid, SqlCode sqlcode, java.lang.Object... args)SqlException(LogWriter logWriter, Sqlca sqlca)Create an exception for an engine generated error.privateSqlException(Sqlca sqlca, int number, boolean chain)Create one of the exceptions in an exception chain generated by the engine.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) SqlExceptioncopyAsUnchainedSQLException(LogWriter logWriter)private java.lang.Object[]getArgs()intgetErrorCode()java.lang.StringgetMessage()static MessageUtilgetMessageUtil()This routine provides singleton access to an instance of MessageUtil that is constructed for client messages.SqlExceptiongetNextException()SqlcagetSqlca()java.sql.SQLExceptiongetSQLException()Convert this SqlException into a java.sql.SQLExceptionjava.lang.StringgetSQLState()(package private) static SqlExceptionjavaException(LogWriter logWriter, java.lang.Throwable e)Helper method to construct an exception which basically says that we encountered an underlying Java exception(package private) voidsetBatchPositionLabel(int index)voidsetNextException(java.sql.SQLException nextException)voidsetNextException(SqlException nextException)private voidsetThrowable(java.lang.Throwable throwable)Set the cause of this exception based on its type.java.lang.StringtoString()
-
-
-
Field Detail
-
DEFAULT_ERRCODE
private static final int DEFAULT_ERRCODE
- See Also:
- Constant Field Values
-
sqlca_
private transient Sqlca sqlca_
-
messageNumber_
private transient int messageNumber_
Tells which of the messages in the SQLCA this exception refers to (counting from 0). For engine generated errors only.
-
message_
private java.lang.String message_
-
cachedMessage_
private java.lang.String cachedMessage_
-
batchPositionLabel_
private java.lang.String batchPositionLabel_
-
sqlstate_
private java.lang.String sqlstate_
-
errorcode_
private int errorcode_
-
causeString_
private java.lang.String causeString_
-
nextException_
protected SqlException nextException_
-
CLIENT_MESSAGE_RESOURCE_NAME
public static final java.lang.String CLIENT_MESSAGE_RESOURCE_NAME
- See Also:
- Constant Field Values
-
exceptionFactory
private static SQLExceptionFactory exceptionFactory
SQLException factory is initialized with default factory. It will be over written by the SQLException factory of the supported JDBC version.
-
msgutil_
private static MessageUtil msgutil_
The message utility instance we use to find messages It's primed with the name of the client message bundle so that it knows to look there if the message isn't found in the shared message bundle.
-
wrappedException_
protected java.sql.SQLException wrappedException_
The wrapped SQLException, if one exists
-
-
Constructor Detail
-
SqlException
SqlException(LogWriter logwriter, ClientMessageId msgid, java.lang.Object[] args, java.lang.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 exceptionmsgid- The message id for this message. ClientMessageId is a simple type-safe wrapper for org.apache.derby.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().
-
SqlException
SqlException(LogWriter logWriter, ClientMessageId msgid, java.lang.Object[] args, SqlCode sqlcode, java.lang.Throwable t)
-
SqlException
public SqlException(LogWriter logWriter, ClientMessageId msgid, SqlCode sqlcode, java.lang.Object... args)
-
SqlException
public SqlException(LogWriter logWriter, ClientMessageId msgid, java.lang.Throwable cause, java.lang.Object... args)
-
SqlException
public SqlException(LogWriter logwriter, ClientMessageId msgid, java.lang.Object... args)
-
SqlException
public SqlException(LogWriter logWriter, Sqlca sqlca)
Create an exception for an engine generated error.- Parameters:
logWriter- object used for tracingsqlca- the SQLCA sent from the server
-
SqlException
private SqlException(Sqlca sqlca, int number, boolean chain)
Create one of the exceptions in an exception chain generated by the engine. This constructor calls itself recursively to create the rest of the exception chain ifchainistrue.- Parameters:
sqlca- the SQLCA sent from the servernumber- the message number for this exception (counting from 0)chain- iftrue, generate the rest of the exception chain recursively and link it to this exception
-
SqlException
private SqlException(LogWriter logWriter, java.lang.String reason, java.lang.String sqlState, int errorCode)
-
SqlException
private SqlException(LogWriter logWriter, java.lang.Throwable throwable, java.lang.String reason, java.lang.String sqlState, int errorCode)
-
SqlException
public SqlException(java.sql.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
-
-
Method Detail
-
getMessageUtil
public static 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
-
setThrowable
private void setThrowable(java.lang.Throwable throwable)
Set the cause of this exception based on its type.SQLExceptions andSqlExceptions are linked withsetNextException()andinitCause(). All other exception types are linked withinitCause().
-
getSQLException
public java.sql.SQLException getSQLException()
Convert this SqlException into a java.sql.SQLException
-
setBatchPositionLabel
void setBatchPositionLabel(int index)
-
getSqlca
public Sqlca getSqlca()
- Specified by:
getSqlcain interfaceDiagnosable
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Throwable
-
getArgs
private java.lang.Object[] getArgs()
-
getMessage
public java.lang.String getMessage()
- Overrides:
getMessagein classjava.lang.Throwable
-
getSQLState
public java.lang.String getSQLState()
-
getErrorCode
public int getErrorCode()
-
getNextException
public SqlException getNextException()
-
setNextException
public void setNextException(SqlException nextException)
-
setNextException
public void setNextException(java.sql.SQLException nextException)
-
javaException
static SqlException javaException(LogWriter logWriter, java.lang.Throwable e)
Helper method to construct an exception which basically says that we encountered an underlying Java exception
-
copyAsUnchainedSQLException
SqlException copyAsUnchainedSQLException(LogWriter logWriter)
-
-