jQuery in Action, 2nd edition*
The moose likes Servlets and the fly likes Wrapping ResultSet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Wrapping ResultSet" Watch "Wrapping ResultSet" New topic
Author

Wrapping ResultSet

Richard Teston
Ranch Hand

Joined: Feb 12, 2002
Posts: 89
Hi
Since resultset cannot be serialize because it does'nt implement Serializable interface, is it possible to wrap it in a class that implements Serializable interface. The reason for this question is that I have an applet displaying data in the database, and one way of communicating servlet to applet is through http tunneling and streaming and i have to access the resultset from the servlets. Is is possible?


The Code is the Programmer
Ravee Bhat
Ranch Hand

Joined: Nov 26, 1999
Posts: 72

declare your ResultSet as transient.
you will have to take care of the restoration work after all the servlet-applet communication.
Paul Lester
Ranch Hand

Joined: Dec 27, 2002
Posts: 40

Hi
Since resultset cannot be serialize because it does'nt implement Serializable interface, is it possible to wrap it in a class that implements Serializable interface

Wrapping it in an object that is serializable won't help because the object and everything that is a member of that object all the way down the object graph must be serializable.
You need to take the data from the result set and put it into a collection of value objects and then either serialize the entire collection to the client or let the servlet handle the collection and only give you the objects that you need.
Paul


Where Photography meets vision.<br /><a href="http://www.photogravision.com" target="_blank" rel="nofollow">http://www.photogravision.com</a><br />Please stop by!<br /> <br />SCJP,SCWCD,SCJD,SCEA
Ruud Steeghs
Ranch Hand

Joined: Jul 09, 2001
Posts: 56
Think you can use the sun.jdbc.rowset.CachedRowset. It is disconnected and serializable.
You can find a jsp example at http://developer.java.sun.com/developer/technicalArticles/javaserverpages/cachedrowset/
Cheers,
Ruud.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Wrapping ResultSet
 
Similar Threads
Resultset
Forwarding resultset from servlet to applet
How to Serialize ResultSet Interface
Serialzation is not working
PAGING EJB's and jsp - Urgent help Needed