Spring - get ResultsSet from query

I would like to use Spring JDBCTemplate , but I would like to get a ResultSet that does not store the complete query result in memory, since you could find a standard operator with java JDBC . The closest I found to the ResultSet was

 SqlRowSet sqlRowSet = template.getJdbcOperations().queryForRowSet(query, queryParameters); 

but does it load the entire database result into memory?

+4
source share
2 answers

If you want to get a ResultSet object using JDBCTemplate, you can get javax.sql.Connection with the following code:

 Connection conn = jdbcTemplate.getDataSource().getConnection(); 

Now you can execute createStatement () or prepareStatement () to get the ResultSet object. This is the only thing that seems to me. Hope this helps you.

+3
source

Is this what you are looking for?

  JdbcTemplate t = new JdbcTemplate(dataSource); t.query("select * from t1", new ResultSetExtractor<Object>() { public Object extractData(ResultSet rs) throws SQLException, DataAccessException { ... process your rs return null; } }); 
+1
source

All Articles