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

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

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

JdbcTemplate.getFetchSize介绍

[英]Return the fetch size specified for this JdbcTemplate.
[中]

代码示例

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

/**
 * Prepare the given JDBC Statement (or PreparedStatement or CallableStatement),
 * applying statement settings such as fetch size, max rows, and query timeout.
 * @param stmt the JDBC Statement to prepare
 * @throws SQLException if thrown by JDBC API
 * @see #setFetchSize
 * @see #setMaxRows
 * @see #setQueryTimeout
 * @see org.springframework.jdbc.datasource.DataSourceUtils#applyTransactionTimeout
 */
protected void applyStatementSettings(Statement stmt) throws SQLException {
  int fetchSize = getFetchSize();
  if (fetchSize != -1) {
    stmt.setFetchSize(fetchSize);
  }
  int maxRows = getMaxRows();
  if (maxRows != -1) {
    stmt.setMaxRows(maxRows);
  }
  DataSourceUtils.applyTimeout(stmt, getDataSource(), getQueryTimeout());
}

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

@Test
public void parameterPropagation() {
  SqlOperation operation = new SqlOperation() {};
  DataSource ds = new DriverManagerDataSource();
  operation.setDataSource(ds);
  operation.setFetchSize(10);
  operation.setMaxRows(20);
  JdbcTemplate jt = operation.getJdbcTemplate();
  assertEquals(ds, jt.getDataSource());
  assertEquals(10, jt.getFetchSize());
  assertEquals(20, jt.getMaxRows());
}

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

@Test
public void testConfig() {
  assertNotNull(jdbcPagingItemReader);
  NamedParameterJdbcTemplate namedParameterJdbcTemplate = (NamedParameterJdbcTemplate)
      ReflectionTestUtils.getField(jdbcPagingItemReader, "namedParameterJdbcTemplate");
  JdbcTemplate jdbcTemplate = (JdbcTemplate) namedParameterJdbcTemplate.getJdbcOperations();
  assertEquals(1000, jdbcTemplate.getMaxRows());
  assertEquals(100, jdbcTemplate.getFetchSize());
}

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

/**
 * Check mandatory properties ({@link DataSource} and
 * {@link #setChannelMessageStoreQueryProvider(ChannelMessageStoreQueryProvider)}). If no {@link MessageRowMapper}
 * and {@link ChannelMessageStorePreparedStatementSetter} was explicitly set using
 * {@link #setMessageRowMapper(MessageRowMapper)} and
 * {@link #setPreparedStatementSetter(ChannelMessageStorePreparedStatementSetter)}  respectively, the default
 * {@link MessageRowMapper} and {@link ChannelMessageStorePreparedStatementSetter} will be instantiate using the
 * specified {@link #deserializer} and {@link #lobHandler}.
 * Also, if the jdbcTemplate's fetchSize property ({@link JdbcTemplate#getFetchSize()})
 * is not 1, a warning will be logged. When using the {@link JdbcChannelMessageStore}
 * with Oracle, the fetchSize value of 1 is needed to ensure FIFO characteristics
 * of polled messages. Please see the Oracle {@link ChannelMessageStoreQueryProvider} for more details.
 * @throws Exception Any Exception.
 */
@Override
public void afterPropertiesSet() throws Exception {
  Assert.state(this.jdbcTemplate != null, "A DataSource or JdbcTemplate must be provided");
  Assert.notNull(this.channelMessageStoreQueryProvider, "A channelMessageStoreQueryProvider must be provided.");
  if (this.messageRowMapper == null) {
    this.messageRowMapper = new MessageRowMapper(this.deserializer, this.lobHandler);
  }
  if (this.jdbcTemplate.getFetchSize() != 1 && logger.isWarnEnabled()) {
    logger.warn("The jdbcTemplate's fetch size is not 1. This may cause FIFO issues with Oracle databases.");
  }
  if (this.preparedStatementSetter == null) {
    this.preparedStatementSetter = new ChannelMessageStorePreparedStatementSetter(this.serializer,
        this.lobHandler);
  }
  this.jdbcTemplate.afterPropertiesSet();
}

代码示例来源:origin: io.bufferslayer/buffer-spring-jdbc

public int getFetchSize() {
 return delegate.getFetchSize();
}

代码示例来源:origin: io.bufferslayer/bufferslayer-spring-jdbc

public int getFetchSize() {
 return delegate.getFetchSize();
}

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

/**
 * Check mandatory properties ({@link DataSource} and
 * {@link #setChannelMessageStoreQueryProvider(ChannelMessageStoreQueryProvider)}). If no {@link MessageRowMapper}
 * and {@link ChannelMessageStorePreparedStatementSetter} was explicitly set using
 * {@link #setMessageRowMapper(MessageRowMapper)} and
 * {@link #setPreparedStatementSetter(ChannelMessageStorePreparedStatementSetter)}  respectively, the default
 * {@link MessageRowMapper} and {@link ChannelMessageStorePreparedStatementSetter} will be instantiate using the
 * specified {@link #deserializer} and {@link #lobHandler}.
 * Also, if the jdbcTemplate's fetchSize property ({@link JdbcTemplate#getFetchSize()})
 * is not 1, a warning will be logged. When using the {@link JdbcChannelMessageStore}
 * with Oracle, the fetchSize value of 1 is needed to ensure FIFO characteristics
 * of polled messages. Please see the Oracle {@link ChannelMessageStoreQueryProvider} for more details.
 * @throws Exception Any Exception.
 */
@Override
public void afterPropertiesSet() throws Exception {
  Assert.state(this.jdbcTemplate != null, "A DataSource or JdbcTemplate must be provided");
  Assert.notNull(this.channelMessageStoreQueryProvider, "A channelMessageStoreQueryProvider must be provided.");
  if (this.messageRowMapper == null) {
    this.messageRowMapper = new MessageRowMapper(this.deserializer, this.lobHandler);
  }
  if (this.jdbcTemplate.getFetchSize() != 1 && logger.isWarnEnabled()) {
    logger.warn("The jdbcTemplate's fetch size is not 1. This may cause FIFO issues with Oracle databases.");
  }
  if (this.preparedStatementSetter == null) {
    this.preparedStatementSetter = new ChannelMessageStorePreparedStatementSetter(this.serializer,
        this.lobHandler);
  }
  this.jdbcTemplate.afterPropertiesSet();
}

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

/**
 * Prepare the given JDBC Statement (or PreparedStatement or CallableStatement),
 * applying statement settings such as fetch size, max rows, and query timeout.
 * @param stmt the JDBC Statement to prepare
 * @throws SQLException if thrown by JDBC API
 * @see #setFetchSize
 * @see #setMaxRows
 * @see #setQueryTimeout
 * @see org.springframework.jdbc.datasource.DataSourceUtils#applyTransactionTimeout
 */
protected void applyStatementSettings(Statement stmt) throws SQLException {
  int fetchSize = getFetchSize();
  if (fetchSize > 0) {
    stmt.setFetchSize(fetchSize);
  }
  int maxRows = getMaxRows();
  if (maxRows > 0) {
    stmt.setMaxRows(maxRows);
  }
  DataSourceUtils.applyTimeout(stmt, getDataSource(), getQueryTimeout());
}

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

/**
 * Prepare the given JDBC Statement (or PreparedStatement or CallableStatement),
 * applying statement settings such as fetch size, max rows, and query timeout.
 * @param stmt the JDBC Statement to prepare
 * @throws SQLException if thrown by JDBC API
 * @see #setFetchSize
 * @see #setMaxRows
 * @see #setQueryTimeout
 * @see org.springframework.jdbc.datasource.DataSourceUtils#applyTransactionTimeout
 */
protected void applyStatementSettings(Statement stmt) throws SQLException {
  int fetchSize = getFetchSize();
  if (fetchSize != -1) {
    stmt.setFetchSize(fetchSize);
  }
  int maxRows = getMaxRows();
  if (maxRows != -1) {
    stmt.setMaxRows(maxRows);
  }
  DataSourceUtils.applyTimeout(stmt, getDataSource(), getQueryTimeout());
}

相关文章