public class SqlExceptionHelper extends Object
Modifier and Type | Class and Description |
---|---|
static class |
SqlExceptionHelper.StandardWarningHandler |
static interface |
SqlExceptionHelper.WarningHandler
Contract for handling
warnings |
static class |
SqlExceptionHelper.WarningHandlerLoggingSupport
Basic support for
SqlExceptionHelper.WarningHandler implementations which log |
Modifier and Type | Field and Description |
---|---|
static SQLExceptionConverter |
DEFAULT_CONVERTER |
static String |
DEFAULT_EXCEPTION_MSG |
static String |
DEFAULT_WARNING_MSG |
static SqlExceptionHelper.StandardWarningHandler |
STANDARD_WARNING_HANDLER |
Constructor and Description |
---|
SqlExceptionHelper()
Create an exception helper with a default exception converter.
|
SqlExceptionHelper(SQLExceptionConverter sqlExceptionConverter)
Create an exception helper with a specific exception converter.
|
Modifier and Type | Method and Description |
---|---|
JDBCException |
convert(SQLException sqlException,
String message)
Convert an SQLException using the current converter, doing some logging first.
|
JDBCException |
convert(SQLException sqlException,
String message,
String sql)
Convert an SQLException using the current converter, doing some logging first.
|
SQLExceptionConverter |
getSqlExceptionConverter()
Access the current exception converter being used internally.
|
void |
handleAndClearWarnings(Connection connection,
SqlExceptionHelper.WarningHandler handler)
General purpose handling of warnings associated with a JDBC
Connection . |
void |
handleAndClearWarnings(Statement statement,
SqlExceptionHelper.WarningHandler handler)
General purpose handling of warnings associated with a JDBC
Statement . |
void |
logAndClearWarnings(Connection connection)
Standard (legacy) behavior for logging warnings associated with a JDBC
Connection and clearing them. |
void |
logExceptions(SQLException sqlException,
String message)
Log the given (and any nested) exception.
|
void |
setSqlExceptionConverter(SQLExceptionConverter sqlExceptionConverter)
Inject the exception converter to use.
|
void |
walkWarnings(SQLWarning warning,
SqlExceptionHelper.WarningHandler handler) |
public static final String DEFAULT_EXCEPTION_MSG
public static final String DEFAULT_WARNING_MSG
public static final SQLExceptionConverter DEFAULT_CONVERTER
public static SqlExceptionHelper.StandardWarningHandler STANDARD_WARNING_HANDLER
public SqlExceptionHelper()
public SqlExceptionHelper(SQLExceptionConverter sqlExceptionConverter)
sqlExceptionConverter
- The exception converter to use.public SQLExceptionConverter getSqlExceptionConverter()
public void setSqlExceptionConverter(SQLExceptionConverter sqlExceptionConverter)
sqlExceptionConverter
- The converter to use.public JDBCException convert(SQLException sqlException, String message)
sqlException
- The exception to convertmessage
- An error message.public JDBCException convert(SQLException sqlException, String message, String sql)
sqlException
- The exception to convertmessage
- An error message.sql
- The SQL being executed when the exception occurredpublic void logExceptions(SQLException sqlException, String message)
sqlException
- The exception to logmessage
- The message text to use as a preamble.public void walkWarnings(SQLWarning warning, SqlExceptionHelper.WarningHandler handler)
public void logAndClearWarnings(Connection connection)
Connection
and clearing them.
Calls handleAndClearWarnings(Connection, WarningHandler)
using STANDARD_WARNING_HANDLER
connection
- The JDBC connection potentially containing warningspublic void handleAndClearWarnings(Connection connection, SqlExceptionHelper.WarningHandler handler)
Connection
.connection
- The JDBC connection potentially containing warningshandler
- The handler for each individual warning in the stack.walkWarnings(java.sql.SQLWarning, org.hibernate.engine.jdbc.spi.SqlExceptionHelper.WarningHandler)
public void handleAndClearWarnings(Statement statement, SqlExceptionHelper.WarningHandler handler)
Statement
.statement
- The JDBC statement potentially containing warningshandler
- The handler for each individual warning in the stack.walkWarnings(java.sql.SQLWarning, org.hibernate.engine.jdbc.spi.SqlExceptionHelper.WarningHandler)
Copyright © 2012 JBoss by Red Hat. All Rights Reserved.