Example usage for org.springframework.jdbc SQLWarningException SQLWarningException

List of usage examples for org.springframework.jdbc SQLWarningException SQLWarningException

Introduction

In this page you can find the example usage for org.springframework.jdbc SQLWarningException SQLWarningException.

Prototype

public SQLWarningException(String msg, SQLWarning ex) 

Source Link

Document

Constructor for SQLWarningException.

Usage

From source file:cc.tooyoung.common.db.JdbcTemplate.java

/**
 * Throw an SQLWarningException if encountering an actual warning.
 * @param warning the warnings object from the current statement.
 * May be <code>null</code>, in which case this method does nothing.
 * @throws SQLWarningException in case of an actual warning to be raised
 */// ww w  .  jav a 2 s . co m
protected void handleWarnings(SQLWarning warning) throws SQLWarningException {
    if (warning != null) {
        throw new SQLWarningException("Warning not ignored", warning);
    }
}

From source file:org.springframework.batch.item.database.AbstractCursorItemReader.java

/**
 * Throw a SQLWarningException if we're not ignoring warnings, else log the
 * warnings (at debug level).//from  w  w w  .j  a va2s  .c  o m
 *
 * @param statement the current statement to obtain the warnings from, if there are any.
 * @throws SQLException if interaction with provided statement fails.
 *
 * @see org.springframework.jdbc.SQLWarningException
 */
protected void handleWarnings(Statement statement) throws SQLWarningException, SQLException {
    if (ignoreWarnings) {
        if (log.isDebugEnabled()) {
            SQLWarning warningToLog = statement.getWarnings();
            while (warningToLog != null) {
                log.debug("SQLWarning ignored: SQL state '" + warningToLog.getSQLState() + "', error code '"
                        + warningToLog.getErrorCode() + "', message [" + warningToLog.getMessage() + "]");
                warningToLog = warningToLog.getNextWarning();
            }
        }
    } else {
        SQLWarning warnings = statement.getWarnings();
        if (warnings != null) {
            throw new SQLWarningException("Warning not ignored", warnings);
        }
    }
}

From source file:org.springframework.jdbc.core.JdbcTemplate.java

/**
 * Throw an SQLWarningException if we're not ignoring warnings.
 * @param warning warning from current statement. May be null,
 * in which case this method does nothing.
 *//*  ww w  .j  a v  a2s.  co  m*/
private void throwExceptionOnWarningIfNotIgnoringWarnings(SQLWarning warning) throws SQLWarningException {
    if (warning != null) {
        if (this.ignoreWarnings) {
            logger.warn("SQLWarning ignored: " + warning);
        } else {
            throw new SQLWarningException("Warning not ignored", warning);
        }
    }
}