I have a table login it has three fields username,password and address(all varchars). I want select all data from the table(select * from login) and store it in a resultset, then i want to get the data from the resultset as i need.like select only the usernames, select all fields for the given username etc; Is there any way that i can retreive data by filtering the resultset.
simply, i dont want to write many queries to retrieve data from a single table.
Joined: Nov 06, 2002
It is not good practice from performance perspective to hold on to a ResultSet. ResultSet opens a cursor to the database.
To address your usecase, you can get the results from the ResultSet and populate an User object (value object / entity object) and maintain these objects in any collection (Map/Set). Close the ResultSet.
You can do many utility operations like getting only the keys, getting particular set of values for any key etc on this collection object.
You can't wake a person who is <b><i>pretending</i></b> to be asleep.<br />Like what <b>"it"</b> does not like - <i> Gurdjieff </i>
Joined: Dec 15, 2005
Originally posted by Rajah Nagur: It is not good practice from performance perspective to hold on to a ResultSet. ResultSet opens a cursor to the database.
True. Just as bad, it also requires you to keep the connection open and allocated for a long time. Database connections are scarce resources too.