#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2002
    Location
    NJ, USA
    Posts
    0
    Rep Power
    0

    Question JSP Design question


    Hi,
    I have to develop a website, where in i have to show a table with data,
    I want to show only 10 records per page, I got a taglib on www.jsptags.com for paging logic which works fine,
    I have a bean which calls a store procedure, and this bean has page scope
    so each time when i load the page, it calls the store proceudre , then this taglib get the resultset and load 10 records,
    when the user clicks on next page link, again the page is loaded and all results extracted and the pages shows next 10.
    so each time i change the page the store procedure is executed.
    Is there a way i can run the store procedure only once and save the resultset and use it for next displays.
    I think one way is to keep the resultset in session and before calling the storeprocedure, check in session , if there is resultset dont call or else call the store procedure.
    Does anyone have a better way of doing it

    Ashish
  2. #2
  3. No Profile Picture
    Clueless llama
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Feb 2001
    Location
    Lincoln, NE. USA
    Posts
    2,353
    Rep Power
    117
    Sounds like a fine way of doing it.
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2001
    Posts
    5
    Rep Power
    0
    If you put the ResultSet in session it stays connected to the database. Result sets are populated as you ask for each row so it keeps the connection open. You can use a CachedRowSet or loop through the ResultSet and store all the data in a Javabean as a Collection like an ArrayList and put that where your pages use it.
  6. #4
  7. No Profile Picture
    Clueless llama
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Feb 2001
    Location
    Lincoln, NE. USA
    Posts
    2,353
    Rep Power
    117
    Yup, I just read that about resultsets. Better to make a databean to store the info.

    I have never heard of a CachedRowSet. Where did you see this?

    EDIT:
    nm, I found it
    http://www.javaworld.com/javaworld/j...cachedrow.html
  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2002
    Location
    NJ, USA
    Posts
    0
    Rep Power
    0
    Hi,
    Thanx for the replies , right now i am using cahced rowset to store the data and use to load the jsp pages, and when ever the user reloads the page, reload the data...
    about cached rowset u can get info at
    http://developer.java.sun.com/develo.../cachedrowset/
    also has anyone developed any logic,if there are say 1 million records in database and need to be displayed 10 at a time.
    also has anyone return a stateless bean ..i hope it may help in this condition...
    Ashish

IMN logo majestic logo threadwatch logo seochat tools logo