this is a posting from another thread that I was looking for clarification on. I understand what's being said but I don't quite understand how to reference the resultSet from this explanation:
*******************************************************************
USE a Scrollable ResultSet object and put it in the session. Keep a variable that identifies where in the resultset ur pointer is at any point of time.
Scrollable ResultSets are a feature only available with JDBC 2.0 onwards... so make sure u have THAT first.
Create a Statement like this...
Statement st =
con.createStatement(ResultSet.SCROLLABLE);
Then run the query n store it in the resultset
ResultSet rs = st.executeQuery(sql);
Then move ur pointer to any record u want with methods present in the ResultSet interface:
relative(int rows) that takes you 'rows' rows ahead.
absolute(int row) that takes your pointer to the 'row'th ROW.
Make sure u use 'refreshRow()' so u have the latest content at any point of time. This refreshes the contents in that row. there is also something called refresh() BUT THAT would minimise performace.
Store this resultset object in the session and call it in each page u want starting with the record number u want to. !!
Hope this helps... aXe!
********************************************
My question is, does someone have a simple example page that does what is described above? Also, to get the number of pages that will be involved, would you first "SELECT * FROM table" and count the rows, divide by the number of rows to display per page, and then create a URL for each number to jump to the next grouping of rows doing something like this?:
(suppose you want 10 rows per page)
2
4
the code would simple do:
<% String page = request.getParameter("page");
rs.absolute(page);
while (rs.next()){ %>
<% ...print out row contents here... %>
<%}%>
Does this sound correct...where does the "refreshRow()" need to go to clear the row? Also, would you need to use LIMIT (to 10 rows)in the SELECT statement?
Any help in understanding this is greatly appreciated!
Chuk.