ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.

advertisement

AddThis Social Bookmark Button
Article:
  Stored Procedures for Java Programmers
Subject:   How to get around Resultset that only move forward.
Date:   2004-11-17 13:39:20
From:   Java_man
With Java if you create a class for each table of the database. By doing this you give yourself the ability to move through the records by creating a programmer defined method that moves through Resultset inside of an object based class. Then you create a control based class that staticly calls preferably using an init(), that all dynamics are done before being sent to the browser. The methods to display can do all the manipulation with simple programming of for loops and if statements.


By doing this we we are able to navigate back in forth through our recordset.


In the example start is the feed from the submission of the concurrent number of which we will want to move.
Dragon is determination of how many records we have. Using a mod we can tell if our total is equal to the amount of records we are going to display on each page, allowing to show exactly how many, where are at and how many are left.
// emprec.next(); is reference to the object class that holds records for the specific table. next() tells the recordset to move forward or how many ased on the feed or whatever specified number of results.



if (start > 1 && start <= dragon)
{
do
{
cntrx++;
} while (emprec.getnext() && cntrx < mover);
}


if (start > 1 && start > dragon)
{
do
{
cntrt++;
start = 1;
} while (emprec.getnext() && cntrt < 0);


}
From this we can then create our links to the next page, either by next or previous, or by numbers, by displaying the criterion specified.


I used this technique with Java Servlets (Tomcat), and MySQL. It is flawless, robust, and interoperable.


1 to 1 of 1
  1. How to get around Resultset that only move forward.
    2005-12-20 02:54:50  sivamca [View]

1 to 1 of 1