Vitaly Lipovetsky wrote:

> "Craig R. McClanahan" wrote:
>
> > Yuki Tanabe wrote:
> >
> >
> > (3)    STORE ENTIRE RESULT SET IN SESSION
> >     AND DYNAMICALLY GENERATE THE PAGES
> >
> > If you can store the results of your query as a Java collection object of some sort
> > in the user's session, then you know exactly how many pages you will need, and you
> > can create them on the fly.  As you create a page of the response, you would add
> > "Previous" and "Next" links at the bottom, which would pass in a parameter that
> > says which page number you want.  The page generator uses that to know how many
> > rows to skip before starting to generate the currently requested page.
> >
> > If you are reading data from a database (via JDBC) to create your response, it is
> > tempting to just store the java.sql.ResultSet containing your results in the
> > session.  This is going to cause scalability problems, however, because it requires
> > leaving the corresponding statement open across multiple HTTP queries (and can
> > cause things like running out of database cursors).  You are better off copying the
> > data into some "disconnected" collection class.
>
> What java class could you offer as "disconnected" collection class ?
> I want to have method in it to fill it from ResultSet.
> And I want that it implements ResultSet interface to use it instead original JDNC
> ResultSet.
> If there is no such a class I will make it then.
>

What I normally do is use custom-built JavaBeans that represent the underlying data as
objects, instead of SQL columns and rows.  In this case, you can just use a Vector or
ArrayList as the collection object in your session.

JavaSoft has also published information on the "javax.sql" (note the "x") standard
extension version 2, which includes an interface called RowSet.  They also offer a cool
implementation called CachedRowSet which has the following properties:

* You initialize it by handing it either
  a connection and a SQL select statement,
  or a result set that you've already opened.

* Once the data is set, the object does not
  refer to the connection.

* The CachedRowSet object itself is serializable,
  so you could even use this to pass database
  results to an applet if you wanted to.

* If you have an appropriate JDBC driver,
  this can also be used to record updates and
  then submit all the appropriate SQL once.

See the JDBC page at JavaSoft's site for more info, including the license conditions on
CachedRowSet:

    http://java.sun.com/products/jdbc

>
> --
> My best regards,
> Vitaly Lipovetsky.
> Head of software development department
> First Ukrainian Intl bank
>

Craig McClanahan

___________________________________________________________________________
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