RESOLVED - BATCH-909: Turn off getWarnings() call in JdbcCursorItemReader when ignoreWarnings is true

getWarnings is now called only if debug is enabled
This commit is contained in:
robokaso
2008-11-10 14:56:31 +00:00
parent 7eb85becdd
commit cec0df8d50

View File

@@ -178,7 +178,7 @@ public class JdbcCursorItemReader<T> extends AbstractItemCountingItemStreamItemR
preparedStatementSetter.setValues(preparedStatement);
}
this.rs = preparedStatement.executeQuery();
handleWarnings(preparedStatement.getWarnings());
handleWarnings(preparedStatement);
}
catch (SQLException se) {
close(null);
@@ -234,20 +234,26 @@ public class JdbcCursorItemReader<T> extends AbstractItemCountingItemStreamItemR
*
* @param warnings the warnings object from the current statement. May be
* <code>null</code>, in which case this method does nothing.
* @throws SQLException
*
* @see org.springframework.jdbc.SQLWarningException
*/
private void handleWarnings(SQLWarning warnings) throws SQLWarningException {
private void handleWarnings(PreparedStatement pstmt) throws SQLWarningException, SQLException {
if (ignoreWarnings) {
SQLWarning warningToLog = warnings;
while (warningToLog != null) {
log.debug("SQLWarning ignored: SQL state '" + warningToLog.getSQLState() + "', error code '"
+ warningToLog.getErrorCode() + "', message [" + warningToLog.getMessage() + "]");
warningToLog = warningToLog.getNextWarning();
if (log.isDebugEnabled()) {
SQLWarning warningToLog = pstmt.getWarnings();
while (warningToLog != null) {
log.debug("SQLWarning ignored: SQL state '" + warningToLog.getSQLState() + "', error code '"
+ warningToLog.getErrorCode() + "', message [" + warningToLog.getMessage() + "]");
warningToLog = warningToLog.getNextWarning();
}
}
}
else if (warnings != null) {
throw new SQLWarningException("Warning not ignored", warnings);
else {
SQLWarning warnings = pstmt.getWarnings();
if (warnings != null) {
throw new SQLWarningException("Warning not ignored", warnings);
}
}
}