-----------------------------
Please read the FAQ!
<http://java.apache.org/faq/>
-----------------------------
[EMAIL PROTECTED] wrote:
> -----------------------------
> Please read the FAQ!
> <http://java.apache.org/faq/>
> -----------------------------
>
>
> Hi,
>
> I've got to append, delete and modify records in an Oracle datafile.
> To do this, I want to have a form in HTML with a navigation bar having
> a next,prev,add,etc. buttons.
>
> My idea was to have a servlet with a public ResultSet where I store a
> query, and have an HttpSession to keep the state of that ResultSet, so
> for example when a click is done to the next button, I would get the
> ResultSet from the session, do a ResultSet.next() and return the HTML
> of the actual register. This can't be possible because
> HttpSession.putValue doesn't seems to support an ResultSet as
> paramater . . .
>
Why not? The second argument to putValue() is of type Object, which can take
anything.
>
> Any idea ?
>
However, you are going to run into a couple of problems with this approach:
* ResultSet in JDK1.1.x scrolls forward only, so you are going to have
to buffer data to implement your "Previous" link.
* A ResultSet is tied to a particular open Statement on a particular
JDBC Connection. If you keep the ResultSet object in your session,
that means you cannot close the Statement, or release the Connection
back to a ConnectionPool.
If the total amount of data selected by your SELECT is reasonably small (i.e.
it will fit in memory), I would load it all the first time into a data
structure of some sort (perhaps an array or a Vector), and store that data
structure -- plus an index variable telling you the current position -- in the
user's session. That way, you can release the database resources for use by
others.
If there is too much data for this to be feasible, you could do something like
storing the SQL text itself, and performing the select each time. You would
also need a parameter that says how many rows to skip before saving this
page's worth of data, or a way to modify the select so that only the relevant
data is pulled each time.
Many search engines on the web use a variant of this technique -- if you look
at the URL they submit when you press "Previous Page" or "Next Page" you will
often see your selection criteria plus a counter that says how many responses
to skip.
>
>
> Alejandro
>
Craig McClanahan
--
--------------------------------------------------------------
Please read the FAQ! <http://java.apache.org/faq/>
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Archives and Other: <http://java.apache.org/main/mail.html>
Problems?: [EMAIL PROTECTED]