Top Fields Constructors Methods
org.apache.derby.client.am

public Class SqlException

Additional top-level classes in compilation unit: ColumnTypeConversionException, OutsideRangeForDataTypeException.

extends Exception
implements Diagnosable
Class Inheritance
All Implemented Interfaces
org.apache.derby.client.am.Diagnosable
Known Direct Subclasses
org.apache.derby.client.am.ColumnTypeConversionException, org.apache.derby.client.am.OutsideRangeForDataTypeException, org.apache.derby.client.am.SqlWarning, org.apache.derby.client.am.DisconnectException
Imports
java.sql.SQLException, org.apache.derby.shared.common.i18n.MessageUtil, org.apache.derby.shared.common.error.ExceptionUtil, org.apache.derby.shared.common.reference.MessageId, .SQLState

Field Summary

Modifier and TypeField and Description
private String
private String
private String
public static final String
private static final int
private int
private static SQLExceptionFactory
exceptionFactory

SQLException factory is initialized with default factory.

private String
private transient int
messageNumber_

Tells which of the messages in the SQLCA this exception refers to (counting from 0).

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.

protected SqlException
private transient Sqlca
private String
protected SQLException
wrappedException_

The wrapped SQLException, if one exists

Constructor Summary

AccessConstructor and Description
pack-priv
SqlException(LogWriter
Can be null, but if provided, it is used to log this exception
logwriter
,
ClientMessageId
The message id for this message. ClientMessageId is a simple type-safe wrapper for org.apache.derby.shared.common.reference.SQLState message id strings.
msgid
,
Object[]
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.
args
,
Throwable
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().
cause
)

Create a SqlException.

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

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

public
SqlException(LogWriter logWriter, ClientMessageId msgid, Throwable cause, Object... args)

public
SqlException(LogWriter logwriter, ClientMessageId msgid, Object... args)

public
SqlException(LogWriter
object used for tracing
logWriter
,
Sqlca
the SQLCA sent from the server
sqlca
)

Create an exception for an engine generated error.

private
SqlException(Sqlca
the SQLCA sent from the server
sqlca
,
int
the message number for this exception (counting from 0)
number
,
boolean
if true, generate the rest of the exception chain recursively and link it to this exception
chain
)

Create one of the exceptions in an exception chain generated by the engine.

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

private
SqlException(LogWriter logWriter, Throwable throwable, String reason, String sqlState, int errorCode)

public
SqlException(SQLException
The original exception
wrapme
)

Wrap a SQLException in a SqlException.

Method Summary

Modifier and TypeMethod and Description
pack-priv SqlException
private Object[]
public int
public String
getMessage()

Overrides java.lang.Throwable.getMessage.

Returns the detail message string of this throwable.
public static MessageUtil

Returns:

a singleton instance of MessageUtil configured for client messages
getMessageUtil
()

This routine provides singleton access to an instance of MessageUtil that is constructed for client messages.

public SqlException
public Sqlca
public SQLException

Returns:

a corresponding SQLException
getSQLException
()

Convert this SqlException into a java.sql.SQLException

public String
pack-priv static SqlException
javaException(LogWriter logWriter, Throwable e)

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

pack-priv void
public void
public void
private void
setThrowable(Throwable throwable)

Set the cause of this exception based on its type.

public String
toString()

Overrides java.lang.Throwable.toString.

Returns a short description of this throwable.

Field Detail

batchPositionLabel_back to summary
private String batchPositionLabel_
cachedMessage_back to summary
private String cachedMessage_
causeString_back to summary
private String causeString_
CLIENT_MESSAGE_RESOURCE_NAMEback to summary
public static final String CLIENT_MESSAGE_RESOURCE_NAME
DEFAULT_ERRCODEback to summary
private static final int DEFAULT_ERRCODE
errorcode_back to summary
private int errorcode_
exceptionFactoryback to summary
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.

message_back to summary
private String message_
messageNumber_back to summary
private transient int messageNumber_

Tells which of the messages in the SQLCA this exception refers to (counting from 0). For engine generated errors only.

msgutil_back to summary
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.

nextException_back to summary
protected SqlException nextException_
sqlca_back to summary
private transient Sqlca sqlca_
sqlstate_back to summary
private String sqlstate_
wrappedException_back to summary
protected SQLException wrappedException_

The wrapped SQLException, if one exists

Constructor Detail

SqlExceptionback to summary
pack-priv 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:LogWriter

Can be null, but if provided, it is used to log this exception

msgid:ClientMessageId

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:Object[]

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:Throwable

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().

SqlExceptionback to summary
pack-priv SqlException(LogWriter logWriter, ClientMessageId msgid, Object[] args, SqlCode sqlcode, Throwable t)
SqlExceptionback to summary
public SqlException(LogWriter logWriter, ClientMessageId msgid, SqlCode sqlcode, Object... args)
SqlExceptionback to summary
public SqlException(LogWriter logWriter, ClientMessageId msgid, Throwable cause, Object... args)
SqlExceptionback to summary
public SqlException(LogWriter logwriter, ClientMessageId msgid, Object... args)
SqlExceptionback to summary
public SqlException(LogWriter logWriter, Sqlca sqlca)

Create an exception for an engine generated error.

Parameters
logWriter:LogWriter

object used for tracing

sqlca:Sqlca

the SQLCA sent from the server

SqlExceptionback to summary
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 if chain is true.

Parameters
sqlca:Sqlca

the SQLCA sent from the server

number:int

the message number for this exception (counting from 0)

chain:boolean

if true, generate the rest of the exception chain recursively and link it to this exception

SqlExceptionback to summary
private SqlException(LogWriter logWriter, String reason, String sqlState, int errorCode)
SqlExceptionback to summary
private SqlException(LogWriter logWriter, Throwable throwable, String reason, String sqlState, int errorCode)
SqlExceptionback to summary
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

Parameters
wrapme:SQLException

The original exception

Method Detail

copyAsUnchainedSQLExceptionback to summary
pack-priv SqlException copyAsUnchainedSQLException(LogWriter logWriter)
getArgsback to summary
private Object[] getArgs()
getErrorCodeback to summary
public int getErrorCode()
getMessageback to summary
public String getMessage()

Overrides java.lang.Throwable.getMessage.

Doc from java.lang.Throwable.getMessage.

Returns the detail message string of this throwable.

Returns:String

the detail message string of this Throwable instance (which may be null).

Annotations
@Override
getMessageUtilback to summary
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:MessageUtil

a singleton instance of MessageUtil configured for client messages

getNextExceptionback to summary
public SqlException getNextException()
getSqlcaback to summary
public Sqlca getSqlca()

Implements org.apache.derby.client.am.Diagnosable.getSqlca.

getSQLExceptionback to summary
public SQLException getSQLException()

Convert this SqlException into a java.sql.SQLException

Returns:SQLException

a corresponding SQLException

getSQLStateback to summary
public String getSQLState()
javaExceptionback to summary
pack-priv static SqlException javaException(LogWriter logWriter, Throwable e)

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

setBatchPositionLabelback to summary
pack-priv void setBatchPositionLabel(int index)
setNextExceptionback to summary
public void setNextException(SqlException nextException)
setNextExceptionback to summary
public void setNextException(SQLException nextException)
setThrowableback to summary
private void setThrowable(Throwable throwable)

Set the cause of this exception based on its type. SQLExceptions and SqlExceptions are linked with setNextException() and initCause(). All other exception types are linked with initCause().

toStringback to summary
public String toString()

Overrides java.lang.Throwable.toString.

Doc from java.lang.Throwable.toString.

Returns a short description of this throwable. The result is the concatenation of:

  • the name of the class of this object
  • ": " (a colon and a space)
  • the result of invoking this object's getLocalizedMessage method
If getLocalizedMessage returns null, then just the class name is returned.
Returns:String

a string representation of this throwable.

Annotations
@Override