public class DbException
extends java.lang.RuntimeException
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
HIDE_SQL
If the SQL statement contains this text, then it is never added to the
SQL exception.
|
static java.sql.SQLException |
SQL_OOME
Thrown when OOME exception happens on handle error
inside
convert(java.lang.Throwable). |
| Modifier and Type | Method and Description |
|---|---|
DbException |
addSQL(java.lang.String sql)
Set the SQL statement of the given exception.
|
static java.lang.String |
buildMessageForException(JdbcException e)
Builds message for an exception.
|
static DbException |
convert(java.lang.Throwable e)
Convert a throwable to an SQL exception using the default mapping.
|
static DbException |
convertInvocation(java.lang.reflect.InvocationTargetException te,
java.lang.String message)
Convert an InvocationTarget exception to a database exception.
|
static DbException |
convertIOException(java.io.IOException e,
java.lang.String message)
Convert an IO exception to a database exception.
|
static DbException |
fromUser(java.lang.String sqlstate,
java.lang.String message)
Create a database exception for an arbitrary SQLState.
|
static DbException |
get(int errorCode)
Create a database exception for a specific error code.
|
static DbException |
get(int errorCode,
java.lang.String... params)
Create a database exception for a specific error code.
|
static DbException |
get(int errorCode,
java.lang.String p1)
Create a database exception for a specific error code.
|
static DbException |
get(int errorCode,
java.lang.Throwable cause,
java.lang.String... params)
Create a database exception for a specific error code.
|
int |
getErrorCode()
Get the error code.
|
static DbException |
getFileVersionError(java.lang.String dataFileName)
Gets a file version exception.
|
static java.lang.RuntimeException |
getInternalError()
Gets an internal error.
|
static java.lang.RuntimeException |
getInternalError(java.lang.String s)
Gets an internal error.
|
static DbException |
getInvalidValueException(java.lang.String param,
java.lang.Object value)
Gets a SQL exception meaning this value is invalid.
|
static java.sql.SQLException |
getJdbcSQLException(int errorCode)
Gets the SQL exception object for a specific error code.
|
static java.sql.SQLException |
getJdbcSQLException(int errorCode,
java.lang.String p1)
Gets the SQL exception object for a specific error code.
|
static java.sql.SQLException |
getJdbcSQLException(int errorCode,
java.lang.Throwable cause,
java.lang.String... params)
Gets the SQL exception object for a specific error code.
|
static java.sql.SQLException |
getJdbcSQLException(java.lang.String message,
java.lang.String sql,
java.lang.String state,
int errorCode,
java.lang.Throwable cause,
java.lang.String stackTrace)
Creates a SQLException.
|
java.lang.Object |
getSource() |
java.sql.SQLException |
getSQLException()
Get the SQLException object.
|
static DbException |
getSyntaxError(int errorCode,
java.lang.String sql,
int index,
java.lang.String... params)
Create a syntax error exception for a specific error code.
|
static DbException |
getSyntaxError(java.lang.String sql,
int index)
Create a syntax error exception.
|
static DbException |
getSyntaxError(java.lang.String sql,
int index,
java.lang.String message)
Create a syntax error exception.
|
static DbException |
getUnsupportedException(java.lang.String message)
Gets a SQL exception meaning this feature is not supported.
|
static DbException |
getValueTooLongException(java.lang.String columnOrType,
java.lang.String value,
long valueLength)
Gets a SQL exception meaning this value is too long.
|
static void |
printNextExceptions(java.sql.SQLException e,
java.io.PrintStream s)
Prints up to 100 next exceptions for a specified SQL exception.
|
static void |
printNextExceptions(java.sql.SQLException e,
java.io.PrintWriter s)
Prints up to 100 next exceptions for a specified SQL exception.
|
void |
setSource(java.lang.Object source) |
static java.sql.SQLException |
toSQLException(java.lang.Throwable e)
Convert an exception to a SQL exception using the default mapping.
|
static void |
traceThrowable(java.lang.Throwable e)
Write the exception to the driver manager log writer if configured.
|
public static final java.lang.String HIDE_SQL
public static final java.sql.SQLException SQL_OOME
convert(java.lang.Throwable).public java.sql.SQLException getSQLException()
public int getErrorCode()
public DbException addSQL(java.lang.String sql)
sql - the SQL statementpublic static DbException get(int errorCode)
errorCode - the error codepublic static DbException get(int errorCode, java.lang.String p1)
errorCode - the error codep1 - the first parameter of the messagepublic static DbException get(int errorCode, java.lang.Throwable cause, java.lang.String... params)
errorCode - the error codecause - the cause of the exceptionparams - the list of parameters of the messagepublic static DbException get(int errorCode, java.lang.String... params)
errorCode - the error codeparams - the list of parameters of the messagepublic static DbException fromUser(java.lang.String sqlstate, java.lang.String message)
sqlstate - the state to usemessage - the message to usepublic static DbException getSyntaxError(java.lang.String sql, int index)
sql - the SQL statementindex - the position of the error in the SQL statementpublic static DbException getSyntaxError(java.lang.String sql, int index, java.lang.String message)
sql - the SQL statementindex - the position of the error in the SQL statementmessage - the messagepublic static DbException getSyntaxError(int errorCode, java.lang.String sql, int index, java.lang.String... params)
errorCode - the error codesql - the SQL statementindex - the position of the error in the SQL statementparams - the list of parameters of the messagepublic static DbException getUnsupportedException(java.lang.String message)
message - what exactly is not supportedpublic static DbException getInvalidValueException(java.lang.String param, java.lang.Object value)
param - the name of the parametervalue - the value passedpublic static DbException getValueTooLongException(java.lang.String columnOrType, java.lang.String value, long valueLength)
columnOrType - column with data type or data type namevalue - string representation of value, will be truncated to 80
charactersvalueLength - the actual length of value, -1L if unknownpublic static DbException getFileVersionError(java.lang.String dataFileName)
dataFileName - the name of the databasepublic static java.lang.RuntimeException getInternalError(java.lang.String s)
s - the messagepublic static java.lang.RuntimeException getInternalError()
public static java.sql.SQLException toSQLException(java.lang.Throwable e)
e - the root causepublic static DbException convert(java.lang.Throwable e)
e - the root causepublic static DbException convertInvocation(java.lang.reflect.InvocationTargetException te, java.lang.String message)
te - the root causemessage - the added message or nullpublic static DbException convertIOException(java.io.IOException e, java.lang.String message)
e - the root causemessage - the message or nullpublic static java.sql.SQLException getJdbcSQLException(int errorCode)
errorCode - the error codepublic static java.sql.SQLException getJdbcSQLException(int errorCode,
java.lang.String p1)
errorCode - the error codep1 - the first parameter of the messagepublic static java.sql.SQLException getJdbcSQLException(int errorCode,
java.lang.Throwable cause,
java.lang.String... params)
errorCode - the error codecause - the cause of the exceptionparams - the list of parameters of the messagepublic static java.sql.SQLException getJdbcSQLException(java.lang.String message,
java.lang.String sql,
java.lang.String state,
int errorCode,
java.lang.Throwable cause,
java.lang.String stackTrace)
message - the reasonsql - the SQL statementstate - the SQL stateerrorCode - the error codecause - the exception that was the reason for this exceptionstackTrace - the stack tracepublic static java.lang.String buildMessageForException(JdbcException e)
e - exceptionpublic static void printNextExceptions(java.sql.SQLException e,
java.io.PrintWriter s)
e - SQL exceptions - print writerpublic static void printNextExceptions(java.sql.SQLException e,
java.io.PrintStream s)
e - SQL exceptions - print streampublic java.lang.Object getSource()
public void setSource(java.lang.Object source)
public static void traceThrowable(java.lang.Throwable e)
e - the exception