ResultSet rs = st.executeQuery("SELECT * FROM mytable");
3. Skip the required number of pages by calling rs.next() until you get to the required rowSELECT * FROM tbl LIMIT 5,10; # Retrieve rows 6-15
which means starting at row 6, retrieve the next 10 rows.
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.