File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes CachedRowSet? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "CachedRowSet?" Watch "CachedRowSet?" New topic
Author

CachedRowSet?

Jenn Person
Ranch Hand

Joined: Jan 16, 2005
Posts: 89
Ok, so I'm using the MVC pattern. Right now I've made the model and controller to simply query the database for a list of music category titles, which require no arguments. I have the model query my DB and return a ResultSet, but when the controller tries to process the resultset it doesn't work. Would I need to use a cachedrowset instead to receive the incoming resultset from the model??

Or would it be a better/simpler process to just process the resultset within the model, putting the results into category beans, and then putting those beans into an ArrayList... which I would then return to the controller instead of the resultset?
Anil Sadi
Greenhorn

Joined: Jan 09, 2001
Posts: 23
It depends. If you want to update the data in resultset while you traverse though it and update it back to database, use cachedrowset. If you want the data just to be displayed in JSP page, use Value Obejcts.

Returning the resultset is not fair idea beacuse it keeps the connection open till you close the resultset.

Hope it helps !!!

Anil Sadineni.
Jenn Person
Ranch Hand

Joined: Jan 16, 2005
Posts: 89
Originally posted by Anil Sadi:
It depends. If you want to update the data in resultset while you traverse though it and update it back to database, use cachedrowset. If you want the data just to be displayed in JSP page, use Value Obejcts.

Returning the resultset is not fair idea beacuse it keeps the connection open till you close the resultset.

Hope it helps !!!

Anil Sadineni.


I only want to retrieve the music categories from the database. Any additions, deletions and updates will be made by a seperate controller, and model specifically for admin users only. In short, I want this servlet to be able to get the categories so I can save the info to the application scope. A jsp file which is included on my index and several other pages will access the servlet context to retrieve that info and print out the category titles for users to browse music categories.
Anil Sadi
Greenhorn

Joined: Jan 09, 2001
Posts: 23
Then, best way is use Value Objects. You model should be able to return the collection of value objects(or beans). Your servlet/action class/jsp keeps the data in applicaiton scope. JSP pages iterate through the collection of beans and renders the data.

Anil Sadineni.
Viswa
Greenhorn

Joined: May 17, 2004
Posts: 16
Hi Jenn,
If you compare with ResultSet CachedRowSet is best. B'coz it is connectionless result set. So, you can thro like a ball from one layer to another layer- means from Persistence layer to Presentation layer(CachedRowSet is Serialized one). Iterating and fetch values from CachedRowSet is very easy. If you use java version >=1.4.2 no probs. else you should download it from net.

cheers
vichu
[ March 28, 2005: Message edited by: Vichu ]
 
 
subject: CachedRowSet?