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

[309 byte] By [PaviEluri20a] at [2007-11-27 5:15:53]
# 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.

DrClapa at 2007-7-12 10:38:19 > top of Java-index,Core,Core APIs...
# 2
Thank you very much for your reply. Is it a good practice to put queries in a JSP and have a link to navigate through the result set (like next>>) access result set from a DAO. Pardon me if this sounds insane. Thanks,
PaviEluri20a at 2007-7-12 10:38:19 > top of Java-index,Core,Core APIs...
# 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.

DrClapa at 2007-7-12 10:38:19 > top of Java-index,Core,Core APIs...