Java Reference
In-Depth Information
+ rs.getString(3) +
" - " + rs.getString(4));
rs.next();
System.out.println(rs.getString(2) + ": "
+ rs.getString(3) +
" - " + rs.getString(4));
rs.previous();
System.out.println(rs.getString(2) + ": "
+ rs.getString(3) +
" - " + rs.getString(4));
rs.last();
System.out.println(rs.getString(2) + ": "
+ rs.getString(3) +
" - " + rs.getString(4));
} catch (SQLException ex) {
ex.printStackTrace();
}
}
Executing this method will result in the following output using the data that was
originally loaded for this chapter:
Successfully connected
13-1: Connecting to a Database - DriverManager and
DataSource Implementations - More to Come
13-2: Querying a Database and Retrieving Results
- Obtaining and Using Data from a DBMS
13-1: Connecting to a Database - DriverManager and
DataSource Implementations - More to Come
13-3: Handling SQL Exceptions - Using SQLException
How It Works
Ordinary ResultSet objects allow results to be fetched in a forward direction. That
is, an application can process a default ResultSet object from the first record re-
trieved forward to the last. Sometimes an application requires more functionality when
it comes to traversing a ResultSet . For instance, let's say you want to write an ap-
Search WWH ::




Custom Search