Resultset

Hello

I have a servlet that selects n no. of records from the database .
Afterwards I send this data to the screen using five records at a time .
The page has option of going UP and DOWN . This means that whenever the user clicks UP
, the servlet should show him the next five record and if he clicks on DOWN then the last five records
will be shown .

I have written a servlet which selects n no of records and displays the first 5.
next when he clicks UP I have to execute another servlet whick should display the next five records .
now in the first case I have already executed a select statemnt and I have the resultset . So in
the second case ( I mean when I click UP) I don't want to execute another SQL statemnt , instead I
want to use the existing resultset .

How should I do .
Thanks in advance.
bye
Biswajit
[899 byte] By [Biswajit] at [2007-11-15 20:12:45]
# 1 Re: Resultset
Hi,
If you are using JDK1.2 and above, you can move
back and forth between the records by using the
methods previous() and next(). You also have
a method called moveRelative(). I am not sure
about its exact name. Ofcourse you need to
maintain a recordno variable when you click the
Up or Down buttons.
If you are using a version earlier to JDK1.2,
I think you need to cache the records say like
in a Vector because it doesn't have the
movePrevious() method.

Good luck.
Kannan
kannanbalu at 2007-11-10 2:53:42 >
# 2 Re: Resultset
Hi
I tried to use the session object to store the resultset object .
lets say I have one servlet test1 which creates the resultset .After the resultset is created
I code like this to store the resultset object into the session object : rs is the Resultset
HttpSession session = request.getSession(true);
session.putValue("recordset",rs);
Afterwards I execute another servlet say test2 which should read the result set object and do the need full. The code for receiving the
Resultset is as below .
Httpession session = request.getSession(true);
ResultSet rs = (ResultSet) session.getValue("recordset");
the I execute while (rs.next()) to retrieve the next record from the resultset .
But whenever I execute this I get an exception " NullPointerException"
.
I would like to know whether the way I am doing is conceptually correct ?
Can I store the Resultset Object in Session Object ?
If not , why ?
If I can't store the resultset object in Session Object then how should I proceed ?

Thanks in advance!
Biswajit
Biswajit at 2007-11-10 2:54:42 >