I would like to use Spring JDBCTemplate but I would like to receive a ResultSet, which is not storing full query result in memory, as you would find executing standard statement with java JDBC. The closest I found to the ResultSet was 
SqlRowSet sqlRowSet = template.getJdbcOperations().queryForRowSet(query, queryParameters);
but this loads the whole DB result into memory?
BeanPropertyRowMapper is a RowMapper implementation that converts a table row into a new instance of the specified mapped target class. The mapped target class must be a top-level class and it must have a default or no-arg constructor.
The next() method of the ResultSet interface moves the pointer of the current (ResultSet) object to the next row, from the current position. Statement stmt = con. createStatement(); ResultSet rs = stmt. executeQuery("Select * from MyPlayers"); rs. next();
If you want to get a ResultSet object with JDBCTemplate you can retrieve the javax.sql.Connection with the following code:
Connection conn = jdbcTemplate.getDataSource().getConnection();
And you can now perform a createStatement() or preparedStatement() to get the ResultSet object. That's the only way it comes to my mind. I hope this will help you.
Is it 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;
        }
    });
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With