Access resultset from database using collections.
Hi,
I am retrieving data from DB(Oracle) and inserting it into a table and sort-on colum (subsort on multiple columns according to constraints).
Can someone plz tell me whether using collections is a better way of doing it or a DB query? I don't want to access DB repeatedly.
Thanks
# 1
> Can someone plz tell me whether using collections is
> a better way of doing it or a DB query? I don't want
> to access DB repeatedly.
You need both. Use the DB query to create a ResultSet, then copy the rows into a List of objects. You do need to access the DB once.
# 3
It's a good practice to do what I said in a servlet, or in some kind of helper class. The "list of objects" I mentioned would be a list of DAO's. It isn't a good practice to put anything except view code (HTML, usually) in your JSP, and code that extracts from the database isn't view code.