/** * Set the fetch size for this RDBMS operation. This is important for processing * large result sets: Setting this higher than the default value will increase * processing speed at the cost of memory consumption; setting this lower can * avoid transferring row data that will never be read by the application. * <p>Default is 0, indicating to use the driver's default. * @see org.springframework.jdbc.core.JdbcTemplate#setFetchSize */ public void setFetchSize(int fetchSize) { this.jdbcTemplate.setFetchSize(fetchSize); }
/** * 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()); }
template.setDataSource(this.dataSource); if (fetchSize != null) { template.setFetchSize(fetchSize.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); }
/** * @param host database host * @param port database port * @param database database name * @param username db username * @param password db username's password */ public NominatimConnector(String host, int port, String database, String username, String password) { BasicDataSource dataSource = new BasicDataSource(); dataSource.setUrl(String.format("jdbc:postgres_jts://%s:%d/%s", host, port, database)); dataSource.setUsername(username); dataSource.setPassword(password); dataSource.setDriverClassName(JtsWrapper.class.getCanonicalName()); dataSource.setDefaultAutoCommit(false); template = new JdbcTemplate(dataSource); template.setFetchSize(100000); }
/** * Set the fetch size for this RDBMS operation. This is important for processing * large result sets: Setting this higher than the default value will increase * processing speed at the cost of memory consumption; setting this lower can * avoid transferring row data that will never be read by the application. * <p>Default is 0, indicating to use the driver's default. * @see org.springframework.jdbc.core.JdbcTemplate#setFetchSize */ public void setFetchSize(int fetchSize) { this.jdbcTemplate.setFetchSize(fetchSize); }
/** * Set the fetch size for this RDBMS operation. This is important for processing * large result sets: Setting this higher than the default value will increase * processing speed at the cost of memory consumption; setting this lower can * avoid transferring row data that will never be read by the application. * <p>Default is 0, indicating to use the driver's default. * @see org.springframework.jdbc.core.JdbcTemplate#setFetchSize */ public void setFetchSize(int fetchSize) { this.jdbcTemplate.setFetchSize(fetchSize); }
private void setStatementFetchSizeForStreaming() { jdbcTemplate.setFetchSize(10000); }
public void setFetchSize(int fetchSize) { delegate.setFetchSize(fetchSize); }
public void setFetchSize(int fetchSize) { delegate.setFetchSize(fetchSize); }
// jdbc statement.setFetchSize(500); // spring JdbcTemplate jdbc = new JdbcTemplate(datasource); jdbc.setFetchSize(500);
private void setStatementFetchSizeForStreaming() { switch (dbType) { case POSTGRESQL: jdbcTemplate.setFetchSize(10000); break; case MYSQL: jdbcTemplate.setFetchSize(Integer.MIN_VALUE); break; default: throw createUnknownDbTypeException(); } }
@Override protected void queryMetasPage(int limit, String query, Object[] params, ResultSetExtractor rse) throws DataAccessException { // NOTE: Postgres with fetch size limit = 0 caches all the data in memory if (jdbcops instanceof JdbcTemplate) { ((JdbcTemplate)jdbcops).setFetchSize(limit); } jdbcops.query(query, params, rse); if (jdbcops instanceof JdbcTemplate) { ((JdbcTemplate)jdbcops).setFetchSize(0); } }
private void setStatementFetchSizeForStreaming() { switch (dbType) { case POSTGRESQL: jdbcTemplate.setFetchSize(10000); break; case MYSQL: jdbcTemplate.setFetchSize(Integer.MIN_VALUE); break; default: throw createUnknownDbTypeException(); } }
/** * 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(); }
@Override public SqlRowSet queryForRowSet(String query, int fetchSize) { JdbcTemplate jdbcTemplate = new StreamingJdbcTemplate(); jdbcTemplate.setDataSource(dataSource); jdbcTemplate.setFetchSize(fetchSize); if(!query.startsWith("select")){ query = "select * from " + query; } return jdbcTemplate.queryForRowSet(query); }