Solved

Browsing the resultSet

Posted on 1998-11-14
1
316 Views
Last Modified: 2010-03-30
I know that I can use method next()to browse forward the resultSet.  However, I want to know how can I browse backward in the resultSet. I use Java 1.1, so I can't use the new method suggested in Java 1.2. Can anyone tell me how to implement the backward browsing and give me the implemention?
0
Comment
Question by:q1w2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 16

Accepted Solution

by:
heyhey_ earned 50 total points
ID: 1227426
you can "browse" the result set only forward.
quote
" A ResultSet provides access to a table of data generated by executing a Statement. The table rows are retrieved in sequence. Within a row its column values can be accessed in any order. "

if you need to access some rows more then once, you'll have to make a copy (cache them)

Vector rows = new Vector();
Vector curRow;
Object elem;

while (resultSet.next())
{
  curRow = new Vector();
  elem = resulSet.getObject(1);
  curRow.addElement(elem);
  elem = resulSet.getObject(2);
  curRow.addElement(elem);
  elem = resulSet.getObject(3);
  curRow.addElement(elem);
// ....
// now curRow has a copy of all objects from the current row of the result set
  rows.addElement(CurRow);
}


now you have all the information from the resultSet cached in the rows vector
if you need field 2 of the third row, you use

Object o - (Vector)(rows.elementAt(3)).elementAt(2);

hope this helps
  heyhey
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question