Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Wrapping ResultSet

 
Richard Teston
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Ravee Bhat
Ranch Hand
Posts: 72
Eclipse IDE Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
 
Ruud Steeghs
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic