3. Skip the required number of pages by calling rs.next() until you get to the required row
ResultSet rs = st.executeQuery("SELECT * FROM mytable");
which means starting at row 6, retrieve the next 10 rows.
SELECT * FROM tbl LIMIT 5,10; # Retrieve rows 6-15
Think about it, you are retrieving millions of record and you are converting it into a java object (or say ResultSet), how much memory will it need to store the entire content ? Somewhere, i done know when, it will definitely end-up with OutOfMemoryError.
But, lets wait for some time. I am sure the other experts will have better solution than above.