jQuery in Action, 3rd edition
The moose likes JDBC and Relational Databases 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
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
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 (rs.next()){
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: 15092

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 8 API documentation
I agree. Here's the link: http://aspose.com/file-tools
subject: how to make a ResultSet scrollable
It's not a secret anymore!