ResultSet - Cursor : rs.next() Taking lot of time

Indeed, by default JDBC use a fetch size of 10.
Thus, if you don't set a greater value, you'll call database for next records exactly 150 times ..., no need to explain drawbacks of round-trips.

All you have to do is to test performance by setting fetchSize to.. 100 for instance :

statement.setFetchSize(100);

You can play with this number to improve performance according to your environnement.


you have more than 1500 rows in your cursor and the rs what is returned by the database is just a reference to that cursor. So when you invoke rs.next(), every time it goes to the database cursr and get you the current record pointed by the cursor pointer.

So obviously it will take some time to go to database every time and fetch a single record for more than 1500 times with every while loop iteration.

Tags:

Java

Oracle

Jdbc