title: NamedParameterJdbcTemplate with very large rowsets
body: <p>Is there a way to return a "normal" resultset instead of a rowset from a <code>NamedParameterJdbcTemplate</code>? The rowset is using too much memory.</p>
  
  <p>I am creating an application to query a database, returning the results as an excel file. The results can be up to a million rows with 20 columns.</p>
  
  <p>I use the <code>NamedParameterJdbcTemplate</code> class to avoid the use of '?', which is really neat.</p>
  
  <p>This my code:</p>
  
  <pre><code>NamedParameterJdbcTemplate jdbcTemplate = new NamedParameterJdbcTemplate(dataSource);
  MapSqlParameterSource paramSource = new MapSqlParameterSource();
  paramSource.addValue("name", name);
  writeExcel(jdbcTemplate.queryForRowSet(pQuery, paramSource), pOutputStream);
  </code></pre>
  
  <p>However, the <code>queryForRowset</code> reads the entire rowset into memory before proceeding. In classical JDBC, you would just open a resultset and read row by row, keeping the connection open but saving memory.</p>