> Hi
> I have a query regarding sessions
>
> Can I store a resultset object retrieved from a database as a session
> object and then retrieve it back
>
> Thanks
> JIgar
>
Hi,

as Chris rightly says it depends on the Database. I wouldn't recommend
storing the ResultSet in the
session object anyway.

A much better solution would be to process the entire result set and store
each record in a class that
mirrors the fields in them.

This has manifold benefits.

You can create Vector pages of these objects, making the delivery of pages
of records much easier.

You are free to navigate backwards and forwards through the pages, something
that is fraught with difficulty
even with JDBC 2.

You get the result set size for free thus freeing you from using count() or
other methods for counting
records.

Database server traffic is minimised, limited to each new query to the
server instead of multiple hits
via sub queries and/or grabbing of records from the result set.

I haven't looked into exactly how the session object actually deals with the
objects it contains. If the
session object loads everything it has into memory when you get it then you
will run the risk of
blowing your heap. If, however, only those objects that you actually recall
using getValue are brought
into memory then there is no heap problem. Perhaps someone else can shed
some light on the subject.

I use this method of processing result set in any case. It works well for
me. It was also recommended
by someone who has much more experience in this field than I, George Reese
author of a few books
on JDBC and SQL.

Hope this 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

Reply via email to