你可以在createStatement时使用光标类型,如:
       Statement stmt = con.createStatement(
                                      ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_READ_ONLY);
       ResultSet rs = stmt.executeQuery("SELECT a, b FROM TABLE2");
       // rs will be scrollable, will not show changes made by others然后就可以任意移动光标了,如:
       rs.absolute(5); // moves the cursor to the fifth row of rs
具体的方法很多,请参见JAVADOC