Reputation: 21
I am getting value from single row using resultSet
. which is better:
Upvotes: 0
Views: 57
Reputation: 4360
If you read a value multiple times from ResultSet
it requires some overhead but since ResultSet
uses client side cache the retrieval will be fast. But it is better/faster to store it in a variable and use it, if it is required to be used multiple times (the difference should be very very small). But as chrylis commented, you should not worry about such small performance hacks.
Upvotes: 0
Reputation: 1323
Reading a value from a ResultSet
does not come for free, and if you have to use the value several times you should store it in a local variable instead of re-reading it each time.
Upvotes: 1