public class DbException extends RuntimeException
| 限定符和类型 | 字段和说明 |
|---|---|
static String |
HIDE_SQL
If the SQL statement contains this text, then it is never added to the
SQL exception.
|
static SQLException |
SQL_OOME
Thrown when OOME exception happens on handle error
inside
convert(java.lang.Throwable). |
| 限定符和类型 | 方法和说明 |
|---|---|
DbException |
addSQL(String sql)
Set the SQL statement of the given exception.
|
static String |
buildMessageForException(JdbcException e)
Builds message for an exception.
|
static DbException |
convert(Throwable e)
Convert a throwable to an SQL exception using the default mapping.
|
static DbException |
convertInvocation(InvocationTargetException te,
String message)
Convert an InvocationTarget exception to a database exception.
|
static DbException |
convertIOException(IOException e,
String message)
Convert an IO exception to a database exception.
|
static DbException |
fromUser(String sqlstate,
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,
String... params)
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.
|
static DbException |
get(int errorCode,
Throwable cause,
String... params)
Create a database exception for a specific error code.
|
int |
getErrorCode()
Get the error code.
|
static DbException |
getFileVersionError(String dataFileName)
Gets a file version exception.
|
static RuntimeException |
getInternalError()
Gets an internal error.
|
static RuntimeException |
getInternalError(String s)
Gets an internal error.
|
static DbException |
getInvalidValueException(String param,
Object value)
Gets a SQL exception meaning this value is invalid.
|
static SQLException |
getJdbcSQLException(int errorCode)
Gets the SQL exception object for a specific error code.
|
static SQLException |
getJdbcSQLException(int errorCode,
String p1)
Gets the SQL exception object for a specific error code.
|
static SQLException |
getJdbcSQLException(int errorCode,
Throwable cause,
String... params)
Gets the SQL exception object for a specific error code.
|
static SQLException |
getJdbcSQLException(String message,
String sql,
String state,
int errorCode,
Throwable cause,
String stackTrace)
Creates a SQLException.
|
Object |
getSource() |
SQLException |
getSQLException()
Get the SQLException object.
|
static DbException |
getSyntaxError(int errorCode,
String sql,
int index,
String... params)
Create a syntax error exception for a specific error code.
|
static DbException |
getSyntaxError(String sql,
int index)
Create a syntax error exception.
|
static DbException |
getSyntaxError(String sql,
int index,
String message)
Create a syntax error exception.
|
static DbException |
getUnsupportedException(String message)
Gets a SQL exception meaning this feature is not supported.
|
static DbException |
getValueTooLongException(String columnOrType,
String value,
long valueLength)
Gets a SQL exception meaning this value is too long.
|
static void |
printNextExceptions(SQLException e,
PrintStream s)
Prints up to 100 next exceptions for a specified SQL exception.
|
static void |
printNextExceptions(SQLException e,
PrintWriter s)
Prints up to 100 next exceptions for a specified SQL exception.
|
void |
setSource(Object source) |
static SQLException |
toSQLException(Throwable e)
Convert an exception to a SQL exception using the default mapping.
|
static void |
traceThrowable(Throwable e)
Write the exception to the driver manager log writer if configured.
|
public static final String HIDE_SQL
public static final SQLException SQL_OOME
convert(java.lang.Throwable).public SQLException getSQLException()
public int getErrorCode()
public DbException addSQL(String sql)
sql - the SQL statementpublic static DbException get(int errorCode)
errorCode - the error codepublic static DbException get(int errorCode, String p1)
errorCode - the error codep1 - the first parameter of the messagepublic static DbException get(int errorCode, Throwable cause, String... params)
errorCode - the error codecause - the cause of the exceptionparams - the list of parameters of the messagepublic static DbException get(int errorCode, String... params)
errorCode - the error codeparams - the list of parameters of the messagepublic static DbException fromUser(String sqlstate, String message)
sqlstate - the state to usemessage - the message to usepublic static DbException getSyntaxError(String sql, int index)
sql - the SQL statementindex - the position of the error in the SQL statementpublic static DbException getSyntaxError(String sql, int index, String message)
sql - the SQL statementindex - the position of the error in the SQL statementmessage - the messagepublic static DbException getSyntaxError(int errorCode, String sql, int index, 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(String message)
message - what exactly is not supportedpublic static DbException getInvalidValueException(String param, Object value)
param - the name of the parametervalue - the value passedpublic static DbException getValueTooLongException(String columnOrType, 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(String dataFileName)
dataFileName - the name of the databasepublic static RuntimeException getInternalError(String s)
s - the messagepublic static RuntimeException getInternalError()
public static SQLException toSQLException(Throwable e)
e - the root causepublic static DbException convert(Throwable e)
e - the root causepublic static DbException convertInvocation(InvocationTargetException te, String message)
te - the root causemessage - the added message or nullpublic static DbException convertIOException(IOException e, String message)
e - the root causemessage - the message or nullpublic static SQLException getJdbcSQLException(int errorCode)
errorCode - the error codepublic static SQLException getJdbcSQLException(int errorCode, String p1)
errorCode - the error codep1 - the first parameter of the messagepublic static SQLException getJdbcSQLException(int errorCode, Throwable cause, String... params)
errorCode - the error codecause - the cause of the exceptionparams - the list of parameters of the messagepublic static SQLException getJdbcSQLException(String message, String sql, String state, int errorCode, Throwable cause, 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 String buildMessageForException(JdbcException e)
e - exceptionpublic static void printNextExceptions(SQLException e, PrintWriter s)
e - SQL exceptions - print writerpublic static void printNextExceptions(SQLException e, PrintStream s)
e - SQL exceptions - print streampublic Object getSource()
public void setSource(Object source)
public static void traceThrowable(Throwable e)
e - the exceptionCopyright © 2022. All rights reserved.