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.
SCJP 1.4
Rajah Nagur
Ranch Hand
Joined: Nov 06, 2002
Posts: 239
posted
0
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>
stu derby
Ranch Hand
Joined: Dec 15, 2005
Posts: 333
posted
0
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.
surendar prabu
Ranch Hand
Joined: Jul 24, 2006
Posts: 102
posted
0
Thank you Rajah.
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.