

Then, how many data is loaded? It is configurable. The data is fetch on request. while when you do the execute() you are fetching for the first time. Note this cursor is different from that of DB while it is a pointer initially positioned before the first row of data.


We access data in Resultset via a cursor. Retrieve the ResultSet objects returned from the query by repeatedly calling Statement.getResutSet. Use this method if the query could return one or more ResultSet objects. The question comes into mind is: when I execute the SQL, how is the result being loaded? Immediately or on request? same as this SO threadįirst we need to understand some basics of JDBC, as from OracleĮxecute: Returns true if the first object that the query returns is a ResultSet object. Here is a very detailed explanation on ROW-NUM who are the 5 highest paid employee, which is optimizedįrom ( YOUR_QUERY_GOES_HERE - including the order by ) a In Oracle, it use the same form as to handle “Top-N query” e.g. operating on piecemeal result set (New Query for Each Page)įor MySQL / many other SQLs it can be done with limit and offset.Thus here I formulated the generalized answer:īesides Hibernate pagination, we can use SQL pagination / JDBC pagination While I am using Oracle 11g with Spring’s jdbctemplate, the methods details seems quite scattered. I am a lazy developer who used to pagination API like that provided by Hibernate, thus I expected the answer to be simpler. The solution is clear, it is about implementation. In case of complicated where clause, of course it is slower This is what pagination comes into place – load results page by page. The dataset in DB is too large to be fetch by your java app without a OutOfMemoryException Recently at work I faced this classic problem:
