Java Reference
In-Depth Information
if(i==2)System.out.print("\t");
}
while (rs.next()) {
for(int i=1;i<=nColumns;i++){
System.out.print(rs.getString(i)+((i==nColumns)?"\n":"\t"));
}
}
while (rs.previous()) {
for(int i=1;i<=nColumns;i++){
System.out.print(rs.getString(i)+((i==nColumns)?"\n":"\t"));
}
}
}
catch(ClassNotFoundException e){
e.printStackTrace();
}
catch(SQLException e){
e.printStackTrace();
}
}
As you can see from the screen shot of Figure 4 -3 , the example first prints three rows
in first-to -last order and prints them again in reverse:
Figure 4-3: Printing rows from a scrollable result set
Moving the Cursor to a Designated Row
In addition to using the next() and previous() methods to scroll forward and backward,
you can move the cursor to a particular row by using the following methods:
 
first()
 
last()
 
beforeFirst()
 
afterLast()
 
absolute(int rowNumber)
 
relative(int rowNumber)
The effect of the first four of these is apparent from the method names.
Search WWH ::




Custom Search