Solved

Browsing the resultSet

Posted on 1998-11-14
1
312 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
even odd program using while loop 3 72
ejb wildfly example 2 70
Convert from a json string array to a Java object 3 63
maven disable workspace resolution 1 37
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

762 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