使用rs.next()从指定行检索数据

时间:2015-04-11 13:56:13

标签: java ojdbc

我可以使用rs.next()来检索存储在我想要的任何行的数据吗?更确切地说,我知道rs.next()将遍历所有行并提取数据。但是假设我想要数据,例如存储在第10行的名称和卷号。是否有任何可能的方法来实现这一点?总行数为30,例如

好的,我想要做的是:

while(rs.next())
{
Blob b=rs.get blob("imagename");

byte barr[]=new byte(3,(int)      

b.length());//create an array to store
data from blob

Image  
IMG=jpane.getToolKit.default      
tool kit.drawImage(barr);
//jpane is the  frame on which I want to draw    the image

ImageIcon icon=new   

ImageIcon(IMG);

JLabel label=new JLabel(icon);
//passing generated icon to label

 label.revalidate();

 label.repaint();

Jpane.add(label);//adding label to    my     frame

 Jpane.repaint();

Jpane.revalidate();
    }

这样做只是在第一行绘制图像。那么如何绘制任何给定索引处的图像?

2 个答案:

答案 0 :(得分:1)

尝试ResultSet.absolute(int)

rs.absolute(10);// moves the cursor to the 10th row of rs

答案 1 :(得分:0)

如果您只需要第10行,为什么不更改查询以仅返回特定记录?

相关问题