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:
Serializable
,Diagnosable
- Direct Known Subclasses:
ColumnTypeConversionException
,DisconnectException
,OutsideRangeForDataTypeException
,SqlWarning
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate String
private String
private String
static final String
private static final int
private int
private static SQLExceptionFactory
SQLException factory is initialized with default factory.private String
private int
Tells which of the messages in the SQLCA this exception refers to (counting from 0).private static MessageUtil
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 SqlException
private Sqlca
private String
protected SQLException
The wrapped SQLException, if one exists -
Constructor Summary
ConstructorsModifierConstructorDescriptionSqlException
(SQLException wrapme) Wrap a SQLException in a SqlException.private
SqlException
(LogWriter logWriter, String reason, String sqlState, int errorCode) private
SqlException
(LogWriter logWriter, Throwable throwable, String reason, String sqlState, int errorCode) SqlException
(LogWriter logwriter, ClientMessageId msgid, Object... args) (package private)
SqlException
(LogWriter logwriter, ClientMessageId msgid, Object[] args, Throwable cause) Create a SqlException.(package private)
SqlException
(LogWriter logWriter, ClientMessageId msgid, Object[] args, SqlCode sqlcode, Throwable t) SqlException
(LogWriter logWriter, ClientMessageId msgid, Throwable cause, Object... args) SqlException
(LogWriter logWriter, ClientMessageId msgid, SqlCode sqlcode, Object... args) SqlException
(LogWriter logWriter, Sqlca sqlca) Create an exception for an engine generated error.private
SqlException
(Sqlca sqlca, int number, boolean chain) Create one of the exceptions in an exception chain generated by the engine. -
Method Summary
Modifier and TypeMethodDescription(package private) SqlException
copyAsUnchainedSQLException
(LogWriter logWriter) private Object[]
getArgs()
int
static MessageUtil
This routine provides singleton access to an instance of MessageUtil that is constructed for client messages.getSqlca()
Convert this SqlException into a java.sql.SQLException(package private) static SqlException
javaException
(LogWriter logWriter, Throwable e) Helper method to construct an exception which basically says that we encountered an underlying Java exception(package private) void
setBatchPositionLabel
(int index) void
setNextException
(SQLException nextException) void
setNextException
(SqlException nextException) private void
setThrowable
(Throwable throwable) Set the cause of this exception based on its type.toString()
Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace
-
Field Details
-
DEFAULT_ERRCODE
private static final int DEFAULT_ERRCODE- See Also:
-
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_
-
cachedMessage_
-
batchPositionLabel_
-
sqlstate_
-
errorcode_
private int errorcode_ -
causeString_
-
nextException_
-
CLIENT_MESSAGE_RESOURCE_NAME
- See Also:
-
exceptionFactory
SQLException factory is initialized with default factory. It will be over written by the SQLException factory of the supported JDBC version. -
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_
The wrapped SQLException, if one exists
-
-
Constructor Details
-
SqlException
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 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, Object[] args, SqlCode sqlcode, Throwable t) -
SqlException
-
SqlException
-
SqlException
-
SqlException
Create an exception for an engine generated error.- Parameters:
logWriter
- object used for tracingsqlca
- the SQLCA sent from the server
-
SqlException
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 ifchain
istrue
.- 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
-
SqlException
-
SqlException
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 Details
-
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
Set the cause of this exception based on its type.SQLException
s andSqlException
s are linked withsetNextException()
andinitCause()
. All other exception types are linked withinitCause()
. -
getSQLException
Convert this SqlException into a java.sql.SQLException -
setBatchPositionLabel
void setBatchPositionLabel(int index) -
getSqlca
- Specified by:
getSqlca
in interfaceDiagnosable
-
toString
-
getArgs
-
getMessage
- Overrides:
getMessage
in classThrowable
-
getSQLState
-
getErrorCode
public int getErrorCode() -
getNextException
-
setNextException
-
setNextException
-
javaException
Helper method to construct an exception which basically says that we encountered an underlying Java exception -
copyAsUnchainedSQLException
-