Reputation: 338
I am keen in knowing the working of ResultSet in depth. I have got many doubts regarding ResultSet. such as performance wise which one is better.
while(rs.next())
{
// iterate as well as do call some other functions.
}
or
while(rs.next())
{
// iterate and store the column values in a map
}
// do functions using the map.
since the table is accessed by many other concurrent programs.
Upvotes: 1
Views: 335
Reputation: 172
The best thing to do is, The standard that generally follows is to store all the values into an object and then return that object. This is nothing but a Data Transfer Object (DTO Design pattern).
In the first case, you are doing like
And iterating of the ResultSet, In this step: you are going to call some other functions and we don't know how much time it will take to complete.
The main disadvantage is that holding down the connection object is not good for long time, because it may be required by some other user, and of course it is a costliest one.
Upvotes: 1
Reputation: 2471
Its going to depend on a lot of factors.
Take a look at the CPU and Memory profiling in the free VisualVM, or use some basic timings to get a feel for what's going on.
Upvotes: 1