/** * Set the maximum number of rows for this RDBMS operation. This is important * for processing subsets of large result sets, avoiding to read and hold * the entire result set in the database or in the JDBC driver. * <p>Default is 0, indicating to use the driver's default. * @see org.springframework.jdbc.core.JdbcTemplate#setMaxRows */ public void setMaxRows(int maxRows) { this.jdbcTemplate.setMaxRows(maxRows); }
jt.setMaxRows(50000); jt.setQueryTimeout(queryTimeout);
/** * Check mandatory properties. * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet() */ @Override public void afterPropertiesSet() throws Exception { super.afterPropertiesSet(); Assert.notNull(dataSource, "DataSource may not be null"); JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); if (fetchSize != VALUE_NOT_SET) { jdbcTemplate.setFetchSize(fetchSize); } jdbcTemplate.setMaxRows(getPageSize()); namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(jdbcTemplate); Assert.notNull(queryProvider, "QueryProvider may not be null"); queryProvider.init(dataSource); this.firstPageSql = queryProvider.generateFirstPageQuery(getPageSize()); this.remainingPagesSql = queryProvider.generateRemainingPagesQuery(getPageSize()); }
@PostConstruct public void init() { BasicDataSource ds = new BasicDataSource(); ds.setDriverClassName(JDBC_DRIVER_NAME); ds.setUrl("jdbc:derby:" + NACOS_HOME + File.separator + DERBY_BASE_DIR + ";create=true"); ds.setUsername(USER_NAME); ds.setPassword(PASSWORD); ds.setInitialSize(20); ds.setMaxActive(30); ds.setMaxIdle(50); ds.setMaxWait(10000L); ds.setPoolPreparedStatements(true); ds.setTimeBetweenEvictionRunsMillis(TimeUnit.MINUTES .toMillis(10L)); ds.setTestWhileIdle(true); jt = new JdbcTemplate(); jt.setMaxRows(50000); jt.setQueryTimeout(5000); jt.setDataSource(ds); DataSourceTransactionManager tm = new DataSourceTransactionManager(); tjt = new TransactionTemplate(tm); tm.setDataSource(ds); tjt.setTimeout(5000); if (STANDALONE_MODE && !propertyUtil.isStandaloneUseMysql()) { reload(); } }
template.setMaxRows(maxRows.intValue());
/** * The JDBC {@link DataSource} to use when interacting with the database. * The passed-in {@link DataSource} is used to instantiate a {@link JdbcTemplate} * with {@link JdbcTemplate#setFetchSize(int)} set to <code>1</code> * and with {@link JdbcTemplate#setMaxRows(int)} set to <code>1</code>. * @param dataSource a {@link DataSource} */ public void setDataSource(DataSource dataSource) { this.jdbcTemplate = new JdbcTemplate(dataSource); this.jdbcTemplate.setFetchSize(1); this.jdbcTemplate.setMaxRows(1); }
/** * Create a {@link org.springframework.integration.store.MessageStore} * with all mandatory properties. The passed-in * {@link DataSource} is used to instantiate a {@link JdbcTemplate} * with {@link JdbcTemplate#setFetchSize(int)} set to <code>1</code> * and with {@link JdbcTemplate#setMaxRows(int)} set to <code>1</code>. * @param dataSource a {@link DataSource} */ public JdbcChannelMessageStore(DataSource dataSource) { this(); this.jdbcTemplate = new JdbcTemplate(dataSource); this.jdbcTemplate.setFetchSize(1); this.jdbcTemplate.setMaxRows(1); }
@Override public void execute() { if (isDryRun()) { return; } List<Map<String, Object>> rows; do { ourLog.info("Querying for up to {} rows", myBatchSize); rows = getTxTemplate().execute(t -> { JdbcTemplate jdbcTemplate = newJdbcTemnplate(); jdbcTemplate.setMaxRows(myBatchSize); return jdbcTemplate.query(mySql, new ColumnMapRowMapper()); }); ourLog.info("Processing {} rows", rows.size()); List<Map<String, Object>> finalRows = rows; getTxTemplate().execute(t -> { for (Map<String, Object> nextRow : finalRows) { myConsumer.accept(nextRow); } return null; }); } while (rows.size() > 0); } }
getTxTemplate().execute(t -> { JdbcTemplate jdbcTemplate = newJdbcTemnplate(); jdbcTemplate.setMaxRows(100000); String sql = "SELECT * FROM " + getTableName() + " WHERE " + getColumnName() + " IS NULL"; ourLog.info("Finding up to {} rows in {} that requires hashes", myBatchSize, getTableName());
/** * Set the maximum number of rows for this RDBMS operation. This is important * for processing subsets of large result sets, avoiding to read and hold * the entire result set in the database or in the JDBC driver. * <p>Default is 0, indicating to use the driver's default. * @see org.springframework.jdbc.core.JdbcTemplate#setMaxRows */ public void setMaxRows(int maxRows) { this.jdbcTemplate.setMaxRows(maxRows); }
/** * Set the maximum number of rows for this RDBMS operation. This is important * for processing subsets of large result sets, avoiding to read and hold * the entire result set in the database or in the JDBC driver. * <p>Default is 0, indicating to use the driver's default. * @see org.springframework.jdbc.core.JdbcTemplate#setMaxRows */ public void setMaxRows(int maxRows) { this.jdbcTemplate.setMaxRows(maxRows); }
public void setMaxRows(int maxRows) { delegate.setMaxRows(maxRows); }
public void setMaxRows(int maxRows) { delegate.setMaxRows(maxRows); }
@Override public void setMaxMessagesPerPoll(int maxMessagesPerPoll) { super.setMaxMessagesPerPoll(maxMessagesPerPoll); if (jdbcTemplate != null) { jdbcTemplate.setMaxRows(maxMessagesPerPoll); } }
/** * The JDBC {@link DataSource} to use when interacting with the database. * The passed-in {@link DataSource} is used to instantiate a {@link JdbcTemplate} * with {@link JdbcTemplate#setFetchSize(int)} set to <code>1</code> * and with {@link JdbcTemplate#setMaxRows(int)} set to <code>1</code>. * @param dataSource a {@link DataSource} */ public void setDataSource(DataSource dataSource) { this.jdbcTemplate = new JdbcTemplate(dataSource); this.jdbcTemplate.setFetchSize(1); this.jdbcTemplate.setMaxRows(1); }
/** * Create a {@link org.springframework.integration.store.MessageStore} * with all mandatory properties. The passed-in * {@link DataSource} is used to instantiate a {@link JdbcTemplate} * with {@link JdbcTemplate#setFetchSize(int)} set to <code>1</code> * and with {@link JdbcTemplate#setMaxRows(int)} set to <code>1</code>. * @param dataSource a {@link DataSource} */ public JdbcChannelMessageStore(DataSource dataSource) { this(); this.jdbcTemplate = new JdbcTemplate(dataSource); this.jdbcTemplate.setFetchSize(1); this.jdbcTemplate.setMaxRows(1); }
private <T> List<T> doSelect(String sql, int maxRows, RowMapper<T> rowMapper, Object... params) { JdbcTemplate template = jdbcTemplateMap.get(maxRows); if (template == null) try { lock.lock(); template = new JdbcTemplate(dataSource); template.setFetchSize(maxRows); template.setMaxRows(maxRows); jdbcTemplateMap.put(maxRows, template); } finally{ lock.unlock(); } return doSelect0(template, sql, rowMapper, params); }
public Integer countMessagesWithoutAckForWorker(int maxSize, long minVersionAllowed, String workerUuid) { jdbcTemplate.setMaxRows(maxSize); jdbcTemplate.setFetchSize(maxSize); Object[] values = { workerUuid, ExecStatus.SENT.getNumber(), minVersionAllowed, }; long time = System.currentTimeMillis(); Integer result = jdbcTemplate.queryForObject(QUERY_COUNT_MESSAGES_WITHOUT_ACK_FOR_WORKER_SQL, values,Integer.class); if (logger.isTraceEnabled()) logger.trace("Query [" + QUERY_COUNT_MESSAGES_WITHOUT_ACK_FOR_WORKER_SQL + "] took " + (System.currentTimeMillis() - time) + " ms"); if (logger.isDebugEnabled()) { logger.debug("Got msg without ack :" + result + ",for version:" + minVersionAllowed + ",for worker:" + workerUuid); } return result.intValue(); }
/** * Check mandatory properties. * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet() */ @Override public void afterPropertiesSet() throws Exception { super.afterPropertiesSet(); Assert.notNull(dataSource, "DataSource may not be null"); JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); if (fetchSize != VALUE_NOT_SET) { jdbcTemplate.setFetchSize(fetchSize); } jdbcTemplate.setMaxRows(getPageSize()); namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(jdbcTemplate); Assert.notNull(queryProvider, "QueryProvider may not be null"); queryProvider.init(dataSource); this.firstPageSql = queryProvider.generateFirstPageQuery(getPageSize()); this.remainingPagesSql = queryProvider.generateRemainingPagesQuery(getPageSize()); }
/** * 创建一个SQL实例 */ public SQL sql() { if (this.jdbcTemplate == null) { this.jdbcTemplate = new JdbcTemplate(); this.jdbcTemplate.setIgnoreWarnings(ignoreWarnings); this.jdbcTemplate.setFetchSize(fetchSize); this.jdbcTemplate.setMaxRows(maxRows); this.jdbcTemplate.setQueryTimeout(queryTimeout); this.jdbcTemplate.setSkipResultsProcessing(skipResultsProcessing); this.jdbcTemplate.setSkipUndeclaredResults(skipUndeclaredResults); this.jdbcTemplate.setResultsMapCaseInsensitive(resultsMapCaseInsensitive); this.jdbcTemplate.setDataSource(this.dataSource); } return new SQL(this.jdbcTemplate, this.dataSourceType); }