HHH-9174 Increase performance

of SqlExceptionHelper#handleAndClearWarnings
This commit is contained in:
Brett Meyer 2014-05-09 11:51:06 -04:00
parent 5d8a45ca0c
commit 92bf2b7d57
1 changed files with 11 additions and 6 deletions

View File

@ -284,12 +284,17 @@ public class SqlExceptionHelper {
@SuppressWarnings( {"ThrowableResultOfMethodCallIgnored"} )
public void handleAndClearWarnings( Statement statement,
WarningHandler handler ) {
try {
walkWarnings(statement.getWarnings(), handler);
} catch (SQLException sqlException) {
// workaround for WebLogic
LOG.debug("could not log warnings", sqlException);
}
// See HHH-9174. Statement#getWarnings can be an expensive call for many JDBC libs. Don't do it unless
// the log level would actually allow a warning to be logged.
if (LOG.isEnabled(Level.WARN)) {
try {
walkWarnings(statement.getWarnings(), handler);
} catch (SQLException sqlException) {
// workaround for WebLogic
LOG.debug("could not log warnings", sqlException);
}
}
try {
// Sybase fail if we don't do that, sigh...
statement.clearWarnings();