This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes JDBC and the fly likes how to make a ResultSet  scrollable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "how to make a ResultSet  scrollable" Watch "how to make a ResultSet  scrollable" New topic

how to make a ResultSet scrollable

Gayani Kanchana

Joined: Mar 27, 2007
Posts: 19
Im writing a java web application using net beans 5.5 and SQL server. I want to read same result set twice. therefore i use resultSet.first(). to go to the first record in record set. How ever it throws an exception.
how can I move to first record after i reached end of record set.

Please help.
krishnamoorthy kitcha
Ranch Hand

Joined: Feb 04, 2006
Posts: 96
Hi Gayani Kanchana ,

First of all you had retrieved all the datas from the result set like

ResultSet rs=ps.executeQuery(sql);
int i=0;
while ({
String a =rs.getColumn(i);



you will try like this



same code


check and tell me your feedback

Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14114

Have a look at the API documentation of class java.sql.Connection. There are variants of the methods createStatement(), prepareStatement() and prepareCall() that allow you to specify the result set type. There, you can specify that you need a scrollable result set.

Also, your JDBC driver needs to support scrollable result sets, otherwise it isn't going to work.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
I agree. Here's the link:
subject: how to make a ResultSet scrollable