sandy sean wrote:What is the purpose of resultset.setFetchSize()??
The purpose is what the API documentation says; that's what the documentation is for.
Gives the JDBC driver a hint as to the number of rows that should be fetched from the database when more rows are needed for this ResultSet object.
That's kind of obscure, especially to people who are reading it with a desire about what they want it to mean, so let's read what it actually says.
It's talking about a ResultSet object. So this might be the result of a query which returns a couple of hundred thousand rows, let's say.
And it's talking about fetching rows from the database "when more rows are needed". What could that mean? When the code says "get me the next row", and that row hasn't been fetched from the database, then more rows are needed. That's what it means.
So the default is for the ResultSet to fetch all of those couple of hundred thousand rows. This could blow out your memory. So you could tell the ResultSet to only get one thousand at a time, as it needs them, so you don't run that risk.
Now, does it say somewhere that your program will be notified in some way when the next thousand are fetched? Nope. To your code the ResultSet acts identically whether the fetch size is set or not, except that records will move from the database to your program at different times.