Click here to Skip to main content
15,892,161 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I want to retrieve the data from result set in reverse order using the Previous() method of Resultset pls help.
Posted
Updated 7-Feb-12 22:53pm
v3

Sorry, had added some SQL Tags - a bit confused.

Tutorial on Result Set @ oracle.com[^]

That will probably give you some to work with.
 
Share this answer
 
Comments
Wasim007 8-Feb-12 8:46am    
He i got the Solution here's the example code,

import java.sql.*;

public class Example
{
public static void main(String args[])
{
try
{
int i = 0;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:Example");
Statement s = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
ResultSet rs = s.executeQuery("select vendorid from vendor_detail");

rs.afterLast(); //Moves the curser to the end of the ResultSet object
while(rs.previous())
{
System.out.println(rs.getString(1));
}
rs.close();
s.close();
con.close();
}
catch(ClassNotFoundException ev)
{
System.out.println("Class Not Found Exception");
}
catch(SQLException ev)
{
System.out.println(ev.getMessage());
}
}
}
He i got the Solution here's the example code,

import java.sql.*;

public class Example
{
public static void main(String args[])
{
try
{
int i = 0;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:Example");
Statement s = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
ResultSet rs = s.executeQuery("select vendorid from vendor_detail");

rs.afterLast(); //Moves the curser to the end of the ResultSet object
while(rs.previous())
{
System.out.println(rs.getString(1));
}
rs.close();
s.close();
con.close();
}
catch(ClassNotFoundException ev)
{
System.out.println("Class Not Found Exception");
}
catch(SQLException ev)
{
System.out.println(ev.getMessage());
}
}
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900