如何以相反的顺序从结果集中检索数据 [英] how to retrieve data from resultset in reverse order

查看:85
本文介绍了如何以相反的顺序从结果集中检索数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用Resultset pls help的Previous()方法以相反的顺序从结果集中检索数据.

I want to retrieve the data from result set in reverse order using the Previous() method of Resultset pls help.

推荐答案

对不起,已添加了一些SQL标记-有点困惑.

关于结果集的教程@ oracle.com [
Sorry, had added some SQL Tags - a bit confused.

Tutorial on Result Set @ oracle.com[^]

That will probably give you some to work with.


他为我提供了解决方案的示例代码,

导入java.sql.*;

公共类示例
{
公共静态void main(String args [])
{
试试
{
int i = 0;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
连接con = DriverManager.getConnection("jdbc:odbc:Example");
语句s = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
ResultSet rs = s.executeQuery(从vendor_detail中选择vendorid");

rs.afterLast(); //将光标移动到ResultSet对象的末尾
while(rs.previous())
{
System.out.println(rs.getString(1));
}
rs.close();
s.close();
con.close();
}
catch(ClassNotFoundException ev)
{
System.out.println(未找到类异常");
}
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());
}
}
}


这篇关于如何以相反的顺序从结果集中检索数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆