org.springframework.jdbc.core.JdbcTemplate.handleWarnings()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(4.2k)|赞(0)|评价(0)|浏览(147)

本文整理了Java中org.springframework.jdbc.core.JdbcTemplate.handleWarnings()方法的一些代码示例,展示了JdbcTemplate.handleWarnings()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JdbcTemplate.handleWarnings()方法的具体详情如下:
包路径:org.springframework.jdbc.core.JdbcTemplate
类名称:JdbcTemplate
方法名:handleWarnings

JdbcTemplate.handleWarnings介绍

[英]Throw an SQLWarningException if encountering an actual warning.
[中]如果遇到实际警告,则抛出SQLWarningException。

代码示例

代码示例来源:origin: spring-projects/spring-framework

/**
 * Throw an SQLWarningException if we're not ignoring warnings,
 * else log the warnings (at debug level).
 * @param stmt the current JDBC statement
 * @throws SQLWarningException if not ignoring warnings
 * @see org.springframework.jdbc.SQLWarningException
 */
protected void handleWarnings(Statement stmt) throws SQLException {
  if (isIgnoreWarnings()) {
    if (logger.isDebugEnabled()) {
      SQLWarning warningToLog = stmt.getWarnings();
      while (warningToLog != null) {
        logger.debug("SQLWarning ignored: SQL state '" + warningToLog.getSQLState() + "', error code '" +
            warningToLog.getErrorCode() + "', message [" + warningToLog.getMessage() + "]");
        warningToLog = warningToLog.getNextWarning();
      }
    }
  }
  else {
    handleWarnings(stmt.getWarnings());
  }
}

代码示例来源:origin: spring-projects/spring-framework

applyStatementSettings(cs);
T result = action.doInCallableStatement(cs);
handleWarnings(cs);
return result;

代码示例来源:origin: spring-projects/spring-framework

@Override
@Nullable
public <T> T execute(StatementCallback<T> action) throws DataAccessException {
  Assert.notNull(action, "Callback object must not be null");
  Connection con = DataSourceUtils.getConnection(obtainDataSource());
  Statement stmt = null;
  try {
    stmt = con.createStatement();
    applyStatementSettings(stmt);
    T result = action.doInStatement(stmt);
    handleWarnings(stmt);
    return result;
  }
  catch (SQLException ex) {
    // Release Connection early, to avoid potential connection pool deadlock
    // in the case when the exception translator hasn't been initialized yet.
    String sql = getSql(action);
    JdbcUtils.closeStatement(stmt);
    stmt = null;
    DataSourceUtils.releaseConnection(con, getDataSource());
    con = null;
    throw translateException("StatementCallback", sql, ex);
  }
  finally {
    JdbcUtils.closeStatement(stmt);
    DataSourceUtils.releaseConnection(con, getDataSource());
  }
}

代码示例来源:origin: spring-projects/spring-framework

applyStatementSettings(ps);
T result = action.doInPreparedStatement(ps);
handleWarnings(ps);
return result;

代码示例来源:origin: apache/servicemix-bundles

/**
 * Throw an SQLWarningException if we're not ignoring warnings,
 * else log the warnings (at debug level).
 * @param stmt the current JDBC statement
 * @throws SQLWarningException if not ignoring warnings
 * @see org.springframework.jdbc.SQLWarningException
 */
protected void handleWarnings(Statement stmt) throws SQLException {
  if (isIgnoreWarnings()) {
    if (logger.isDebugEnabled()) {
      SQLWarning warningToLog = stmt.getWarnings();
      while (warningToLog != null) {
        logger.debug("SQLWarning ignored: SQL state '" + warningToLog.getSQLState() + "', error code '" +
            warningToLog.getErrorCode() + "', message [" + warningToLog.getMessage() + "]");
        warningToLog = warningToLog.getNextWarning();
      }
    }
  }
  else {
    handleWarnings(stmt.getWarnings());
  }
}

代码示例来源:origin: org.springframework/org.springframework.jdbc

/**
 * Throw an SQLWarningException if we're not ignoring warnings,
 * else log the warnings (at debug level).
 * @param stmt the current JDBC statement
 * @throws SQLWarningException if not ignoring warnings
 * @see org.springframework.jdbc.SQLWarningException
 */
protected void handleWarnings(Statement stmt) throws SQLException {
  if (isIgnoreWarnings()) {
    if (logger.isDebugEnabled()) {
      SQLWarning warningToLog = stmt.getWarnings();
      while (warningToLog != null) {
        logger.debug("SQLWarning ignored: SQL state '" + warningToLog.getSQLState() + "', error code '" +
            warningToLog.getErrorCode() + "', message [" + warningToLog.getMessage() + "]");
        warningToLog = warningToLog.getNextWarning();
      }
    }
  }
  else {
    handleWarnings(stmt.getWarnings());
  }
}

代码示例来源:origin: org.springframework/org.springframework.jdbc

handleWarnings(cs);
return result;

代码示例来源:origin: apache/servicemix-bundles

applyStatementSettings(cs);
T result = action.doInCallableStatement(cs);
handleWarnings(cs);
return result;

代码示例来源:origin: org.springframework/org.springframework.jdbc

handleWarnings(ps);
return result;

代码示例来源:origin: org.springframework/org.springframework.jdbc

handleWarnings(stmt);
return result;

相关文章