我正在使用jdbcTemplate查询ETL工具并获取结果并使用Apache POI库写入Excel工作表。我有700,000到1,000,000之间的行可以提取和写入。
之前我有以下设置:
jdbcTemplate.query(new CustomPreparedStatementCreator(arg), new ResultSetExtractor<Void>() {
@Override
public Void extractData(ResultSet rs) {
while (rs.next()) {... process sequentially ...}
// caused the connection to remain open for 650 seconds
// setFetchSize was not set so it was default
}
现在我有以下设置:
jdbcTemplate.setFetchSize(200);
SqlRowSet srs = jdbcTemplate.queryForRowSet(sql);
// all the rows are fetched in 60 seconds into memory now
while (srs.next()) {... process sequentially ...} // still takes 600 seconds to write to the worksheet
现在我的问题是: