public class SqlExceptionHelper
extends java.lang.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(java.sql.SQLException sqlException,
java.lang.String message)
Convert an SQLException using the current converter, doing some logging first.
|
JDBCException |
convert(java.sql.SQLException sqlException,
java.lang.String message,
java.lang.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(java.sql.Connection connection,
SqlExceptionHelper.WarningHandler handler)
General purpose handling of warnings associated with a JDBC
Connection . |
void |
handleAndClearWarnings(java.sql.Statement statement,
SqlExceptionHelper.WarningHandler handler)
General purpose handling of warnings associated with a JDBC
Statement . |
void |
logAndClearWarnings(java.sql.Connection connection)
Standard (legacy) behavior for logging warnings associated with a JDBC
Connection and clearing them. |
void |
logAndClearWarnings(java.sql.Statement statement) |
void |
logExceptions(java.sql.SQLException sqlException,
java.lang.String message)
Log the given (and any nested) exception.
|
void |
setSqlExceptionConverter(SQLExceptionConverter sqlExceptionConverter)
Inject the exception converter to use.
|
void |
walkWarnings(java.sql.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(java.sql.SQLException sqlException, java.lang.String message)
sqlException
- The exception to convertmessage
- An error message.public JDBCException convert(java.sql.SQLException sqlException, java.lang.String message, java.lang.String sql)
sqlException
- The exception to convertmessage
- An error message.sql
- The SQL being executed when the exception occurredpublic void logExceptions(java.sql.SQLException sqlException, java.lang.String message)
sqlException
- The exception to logmessage
- The message text to use as a preamble.public void walkWarnings(java.sql.SQLWarning warning, SqlExceptionHelper.WarningHandler handler)
warning
- The warning to walkhandler
- The handlerpublic void logAndClearWarnings(java.sql.Connection connection)
Connection
and clearing them.
Calls handleAndClearWarnings(Connection, WarningHandler)
using STANDARD_WARNING_HANDLER
connection
- The JDBC connection potentially containing warningspublic void logAndClearWarnings(java.sql.Statement statement)
public void handleAndClearWarnings(java.sql.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(java.sql.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-2018 Red Hat, Inc. All Rights Reserved.