public class SqlExceptionHelper extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
SqlExceptionHelper.StandardWarningHandler
Standard SQLWarning handler for logging warnings
|
static interface |
SqlExceptionHelper.WarningHandler
Contract for handling
warnings |
static class |
SqlExceptionHelper.WarningHandlerLoggingSupport
Basic support for
SqlExceptionHelper.WarningHandler implementations which handle warnings |
| Modifier and Type | Field and Description |
|---|---|
static SqlExceptionHelper.StandardWarningHandler |
STANDARD_WARNING_HANDLER
Static access to the standard handler for logging warnings
|
| Constructor and Description |
|---|
SqlExceptionHelper(boolean logWarnings)
Create an exception helper with a default exception converter.
|
SqlExceptionHelper(SQLExceptionConverter sqlExceptionConverter,
boolean logWarnings)
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 |
logAndClearWarnings(Statement statement) |
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)
Generic algorithm to walk the hierarchy of SQLWarnings
|
public static final SqlExceptionHelper.StandardWarningHandler STANDARD_WARNING_HANDLER
public SqlExceptionHelper(boolean logWarnings)
public SqlExceptionHelper(SQLExceptionConverter sqlExceptionConverter, boolean logWarnings)
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)
warning - The warning to walkhandler - The handlerpublic void logAndClearWarnings(Connection connection)
Connection and clearing them.
Calls handleAndClearWarnings(Connection, WarningHandler) using STANDARD_WARNING_HANDLERconnection - The JDBC connection potentially containing warningspublic void logAndClearWarnings(Statement statement)
public 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 © 2001-2022 Red Hat, Inc. All Rights Reserved.