
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. Per javadoc: statement.execute() execute: Returns true if the first object that the query returns is a ResultSet object. 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 Here is a very detailed explanation on ROW-NUM

who are the 5 highest paid employee, which is optimized select * from ( select a.*, rownum rnumį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.


Disclaimer: This blog post on SQL pagination & JDBC pagination is posted by me.ĭisregarding Hibernate pagination, we can use SQL pagination / JDBC pagination
