> I am new in Java domain but the need of the project forced me to adopt it.
I am
> developing a web-based workflow application using swing applets and
servlets. In
> Swing to populate UI elemnts like JTable and JTree it is required to
implement
> data models classes. My idea is to initiate corresponding servlet from
DataModel
> classes of Swing UI elements and the servlet execute the query via JDBC
and pass
> the JDBC RecordSet object to calling DataModel class, where RecordSet
object can
> be used to implement all functions of DataModel.
>
> My limited research reveled me that it is not possible to pass RecordSet
object
> b/c that does not implement Serializable interface but one can pass
RecordSet
> within Vector object.
>
> Kindly suggests me the best approach or comments on the above-mentioned
> approach.
> Thanks in advance.
> Regds.
> Muhammad Azam
>
Hi,
yeah, you can implement wrapper classes that implement Serializable in order
to stores things
that aren't persistent, persistent.
A vector carries a lot of baggage with them so you could do the following
public class PersistentResultSet implements Serializable {
Object stored = null;
public PersistentResultSet(ResultSet stored) {
this.stored = stored;
}
public ResultSet getResultSet() {
return (ResultSet)stored;
}
}
This is a simple persistent placeholder for a record set.
(note that I mimic the Vector ability to hold any object here but singly,
this is not needed).
Serialising causes objects inside them to be stored in some form regardless
as to whether they are
Serializable or not.
Beware though, a ResultSet is a very dynamic object. It can be trapped
between transaction begins
commits and is dependent on its Connection and the Statement that produced
it. There is no guarantee
that you will have anything of use when it comes to unpickling it. Much
better to grab the data, store it
in a DataModel and store that instead (or shove it up to your applet).
Hope that helps
Andy Bailey
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html