类 SqlExceptionHelper
- java.lang.Object
-
- org.hibernate.engine.jdbc.spi.SqlExceptionHelper
-
public class SqlExceptionHelper extends Object
Helper for handling SQLExceptions in various manners.- 作者:
- Steve Ebersole
-
-
嵌套类概要
嵌套类 修饰符和类型 类 说明 static classSqlExceptionHelper.StandardWarningHandlerStandard SQLWarning handler for logging warningsstatic interfaceSqlExceptionHelper.WarningHandlerContract for handlingwarningsstatic classSqlExceptionHelper.WarningHandlerLoggingSupportBasic support forSqlExceptionHelper.WarningHandlerimplementations which handlewarnings
-
字段概要
字段 修饰符和类型 字段 说明 static SqlExceptionHelper.StandardWarningHandlerSTANDARD_WARNING_HANDLERStatic access to the standard handler for logging warnings
-
构造器概要
构造器 构造器 说明 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.
-
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 JDBCExceptionconvert(SQLException sqlException, String message)Convert an SQLException using the current converter, doing some logging first.JDBCExceptionconvert(SQLException sqlException, String message, String sql)Convert an SQLException using the current converter, doing some logging first.SQLExceptionConvertergetSqlExceptionConverter()Access the current exception converter being used internally.voidhandleAndClearWarnings(Connection connection, SqlExceptionHelper.WarningHandler handler)General purpose handling of warnings associated with a JDBCConnection.voidhandleAndClearWarnings(Statement statement, SqlExceptionHelper.WarningHandler handler)General purpose handling of warnings associated with a JDBCStatement.voidlogAndClearWarnings(Connection connection)Standard (legacy) behavior for logging warnings associated with a JDBCConnectionand clearing them.voidlogAndClearWarnings(Statement statement)voidlogExceptions(SQLException sqlException, String message)Log the given (and any nested) exception.voidsetSqlExceptionConverter(SQLExceptionConverter sqlExceptionConverter)Inject the exception converter to use.voidwalkWarnings(SQLWarning warning, SqlExceptionHelper.WarningHandler handler)Generic algorithm to walk the hierarchy of SQLWarnings
-
-
-
字段详细资料
-
STANDARD_WARNING_HANDLER
public static final SqlExceptionHelper.StandardWarningHandler STANDARD_WARNING_HANDLER
Static access to the standard handler for logging warnings
-
-
构造器详细资料
-
SqlExceptionHelper
public SqlExceptionHelper(boolean logWarnings)
Create an exception helper with a default exception converter.
-
SqlExceptionHelper
public SqlExceptionHelper(SQLExceptionConverter sqlExceptionConverter, boolean logWarnings)
Create an exception helper with a specific exception converter.- 参数:
sqlExceptionConverter- The exception converter to use.
-
-
方法详细资料
-
getSqlExceptionConverter
public SQLExceptionConverter getSqlExceptionConverter()
Access the current exception converter being used internally.- 返回:
- The current exception converter.
-
setSqlExceptionConverter
public void setSqlExceptionConverter(SQLExceptionConverter sqlExceptionConverter)
Inject the exception converter to use. NOTE : null is allowed and signifies to use the default.- 参数:
sqlExceptionConverter- The converter to use.
-
convert
public JDBCException convert(SQLException sqlException, String message)
Convert an SQLException using the current converter, doing some logging first.- 参数:
sqlException- The exception to convertmessage- An error message.- 返回:
- The converted exception
-
convert
public JDBCException convert(SQLException sqlException, String message, String sql)
Convert an SQLException using the current converter, doing some logging first.- 参数:
sqlException- The exception to convertmessage- An error message.sql- The SQL being executed when the exception occurred- 返回:
- The converted exception
-
logExceptions
public void logExceptions(SQLException sqlException, String message)
Log the given (and any nested) exception.- 参数:
sqlException- The exception to logmessage- The message text to use as a preamble.
-
walkWarnings
public void walkWarnings(SQLWarning warning, SqlExceptionHelper.WarningHandler handler)
Generic algorithm to walk the hierarchy of SQLWarnings- 参数:
warning- The warning to walkhandler- The handler
-
logAndClearWarnings
public void logAndClearWarnings(Connection connection)
Standard (legacy) behavior for logging warnings associated with a JDBCConnectionand clearing them. CallshandleAndClearWarnings(Connection, WarningHandler)usingSTANDARD_WARNING_HANDLER- 参数:
connection- The JDBC connection potentially containing warnings
-
logAndClearWarnings
public void logAndClearWarnings(Statement statement)
-
handleAndClearWarnings
public void handleAndClearWarnings(Connection connection, SqlExceptionHelper.WarningHandler handler)
General purpose handling of warnings associated with a JDBCConnection.- 参数:
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)
-
handleAndClearWarnings
public void handleAndClearWarnings(Statement statement, SqlExceptionHelper.WarningHandler handler)
General purpose handling of warnings associated with a JDBCStatement.- 参数:
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)
-
-