Java Reference
In-Depth Information
// Add RowSet & Corresponding Keys
jrs.addRowSet(bookAuthors, 1);
jrs.addRowSet(authorWork, 2);
The JoinRowSet can now be used to fetch the results of the join, just as if it were
a normal RowSet . When calling the corresponding methods [ getString() ,
getInt() , and so on] of the JoinRowSet , pass the name of the database column
corresponding to the data you want to store:
while(jrs.next()){
System.out.println(jrs.getInt("ID") + ": " +
jrs.getString("TITLE") + " - " +
jrs.getString("FIRSTNAME") + " " +
jrs.getString("LASTNAME"));
}
Although a JoinRowSet is not needed every day, it can be handy when perform-
ing work against two related sets of data. This holds true especially when the applica-
tion is not connected to a database all the time, or if you are trying to use as few Con-
nection objects as possible.
13-12. Filtering Data in a RowSet
Problem
Your application queries the database and returns a large number of rows. The number
of rows within the cached ResultSet is too large for the user to work with at one
time. You would like to limit the number of rows that are visible so that you can per-
form different activities with different sets of data that have been queried from the
table.
Solution
Use a FilteredRowSet to query the database and store the contents. The
FilteredRowSet can be configured to filter the results that are returned from the
query so that the only contents visible are the rows that you want to see. In the follow-
Search WWH ::




Custom Search