CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Resultset

  1. #1
    Join Date
    May 2000
    Posts
    3

    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


  2. #2
    Join Date
    Jan 2000
    Location
    CA, USA
    Posts
    305

    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





  3. #3
    Join Date
    May 2000
    Posts
    3

    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


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured