DbException

This exception wraps a checked exception. It is used in methods where checked exceptions are not supported, for example in a Comparator.

Methods
static DbException convert(Throwable e)
Convert a throwable to an SQL exception using the default mapping.
static DbException convert(Throwable e)
Convert a throwable to an SQL exception using the default mapping. All errors except the following are re-thrown: StackOverflowError, LinkageError.
Parameters:
e - the root cause
Returns:
the exception object
static DbException convertIOException(IOException e, String message)
Convert an IO exception to a database exception.
static DbException convertIOException(IOException e, String message)
Convert an IO exception to a database exception.
Parameters:
e - the root cause
message - the message or null
Returns:
the database exception object
static DbException convertInvocation(InvocationTargetException te, String message)
Convert an InvocationTarget exception to a database exception.
static DbException convertInvocation(InvocationTargetException te, String message)
Convert an InvocationTarget exception to a database exception.
Parameters:
te - the root cause
message - the added message or null
Returns:
the database exception object
static IOException convertToIOException(Throwable e)
Convert an exception to an IO exception.
static IOException convertToIOException(Throwable e)
Convert an exception to an IO exception.
Parameters:
e - the root cause
Returns:
the IO exception
static DbException fromUser(String sqlstate, String message)
Create a database exception for an arbitrary SQLState.
static DbException fromUser(String sqlstate, String message)
Create a database exception for an arbitrary SQLState.
Parameters:
sqlstate - the state to use
message - the message to use
Returns:
the exception
static DbException get(int errorCode)
Create a database exception for a specific error code.
static DbException get(int errorCode)
Create a database exception for a specific error code.
Parameters:
errorCode - the error code
Returns:
the exception
static DbException get(int errorCode, String p1)
Create a database exception for a specific error code.
static DbException get(int errorCode, String p1)
Create a database exception for a specific error code.
Parameters:
errorCode - the error code
p1 - the first parameter of the message
Returns:
the exception
static DbException get(int errorCode, Throwable cause, String... params)
Create a database exception for a specific error code.
static DbException get(int errorCode, Throwable cause, String... params)
Create a database exception for a specific error code.
Parameters:
errorCode - the error code
cause - the cause of the exception
params - the list of parameters of the message
Returns:
the exception
static DbException get(int errorCode, String... params)
Create a database exception for a specific error code.
static DbException get(int errorCode, String... params)
Create a database exception for a specific error code.
Parameters:
errorCode - the error code
params - the list of parameters of the message
Returns:
the exception
static DbException getInvalidValueException(String param, Object value)
Gets a SQL exception meaning this value is invalid.
static DbException getInvalidValueException(String param, Object value)
Gets a SQL exception meaning this value is invalid.
Parameters:
param - the name of the parameter
value - the value passed
Returns:
the IllegalArgumentException object
static DbException getSyntaxError(String sql, int index)
Create a syntax error exception.
static DbException getSyntaxError(String sql, int index)
Create a syntax error exception.
Parameters:
sql - the SQL statement
index - the position of the error in the SQL statement
Returns:
the exception
static DbException getSyntaxError(String sql, int index, String message)
Create a syntax error exception.
static DbException getSyntaxError(String sql, int index, String message)
Create a syntax error exception.
Parameters:
sql - the SQL statement
index - the position of the error in the SQL statement
message - the message
Returns:
the exception
static DbException getUnsupportedException(String message)
Gets a SQL exception meaning this feature is not supported.
static DbException getUnsupportedException(String message)
Gets a SQL exception meaning this feature is not supported.
Parameters:
message - what exactly is not supported
Returns:
the exception
static RuntimeException throwInternalError(String s)
Throw an internal error.
static RuntimeException throwInternalError(String s)
Throw an internal error. This method seems to return an exception object, so that it can be used instead of 'return', but in fact it always throws the exception.
Parameters:
s - the message
Returns:
the RuntimeException object
Throws:
RuntimeException - the exception
static RuntimeException throwInternalError()
Throw an internal error.
static RuntimeException throwInternalError()
Throw an internal error. This method seems to return an exception object, so that it can be used instead of 'return', but in fact it always throws the exception.
Returns:
the RuntimeException object
static SQLException toSQLException(Throwable e)
Convert an exception to a SQL exception using the default mapping.
static SQLException toSQLException(Throwable e)
Convert an exception to a SQL exception using the default mapping.
Parameters:
e - the root cause
Returns:
the SQL exception object
static void traceThrowable(Throwable e)
Write the exception to the driver manager log writer if configured.
static void traceThrowable(Throwable e)
Write the exception to the driver manager log writer if configured.
Parameters:
e - the exception
DbException addSQL(String sql)
Set the SQL statement of the given exception.
DbException addSQL(String sql)
Set the SQL statement of the given exception. This method may create a new object.
Parameters:
sql - the SQL statement
Returns:
the exception
int getErrorCode()
Get the error code.
int getErrorCode()
Get the error code.
Returns:
the error code
SQLException getSQLException()
Get the SQLException object.
SQLException getSQLException()
Get the SQLException object.
Returns:
the exception
Object getSource()
Object getSource()
void setSource(Object source)
void setSource(Object source)