Java Iterator backed by a ResultSet

后端 未结 17 742
清歌不尽
清歌不尽 2020-12-13 06:51

I\'ve got a class that implements Iterator with a ResultSet as a data member. Essentially the class looks like this:

public class A implements Iterator{
            


        
17条回答
  •  误落风尘
    2020-12-13 07:22

    Do you expect most of the data in your result set to actually be used? If so, pre-cache it. It's quite trivial using eg Spring

      List> rows = jdbcTemplate.queryForList(sql);
      return rows.iterator();
    

    Adjust to suit your taste.

提交回复
热议问题