A ResultSet contains all the rows which satisfied the conditions of an SQL statement. |
The cursor of a ResultSet is initially pointed before the first row, the method next( ) moves the cursor down one row. ResultSet r = stmt.executeQuery("select a,b,c from table1"); while (r.next( )) { //print values for current row int i = r.getInt("a"); double f = r.getDouble("b"); String s = r.getString("c"); System.out.println("row" + i + f + s); } |