Java Reference
In-Depth Information
Table 18-3: Contact List RowSet
fName
lName
firm
street
city
state
zip
phone
Oliver
Dewey
Dewey,Cheatham
and Howe
123
Penny
Lane
New
York
NY
10006
555-
123-
4567
Ichabod
Cheatham
Dewey,Cheatham
and Howe
123
Penny
Lane
New
York
NY
10006
555-
123-
4568
Anne
Howe
Dewey,Cheatham
and Howe
123
Penny
Lane
New
York
NY
10006
555-
123-
4569
Michael
West
Acme Insurance
211 Elm
St
New
York
NY
10007
555-
213-
2346
James
Nateland
Acme Insurance
211 Elm
St
New
York
NY
10007
555-
213-
2347
Bob
Guppy
Nigel Watson and
Sons
17 Main
St
New
York
NY
10007
555-
213-
1114
Nigel
Watson
Nigel Watson and
Sons
17 Main
St
New
York
NY
10007
555-
213-
1115
Seamus
Maloney
Maloney's Pizza
Pub, Inc
211 Pine
St
New
York
NY
10007
555-
233-
3335
To retrieve the data as a CachedRowSet , create a CachedRowSet object and use it to execute the
stored procedure. The example shown in Listing 18-7 uses the CachedRowSet implementation from
the Sun rowset jar file, loading it using the jdbc:odbc bridge. As you can see, the code is very similar
to the JDBCRowSet examples, with the exception that rather than displaying the CachedRowSet , the
serializeRows() method serializes the entire CachedRowSet bean to a file.
Listing 18-7: Executing a SQL query in a CachedRowSet
package JavaDatabaseBible.ch18;
import java.io.*;
import java.sql.*;
import javax.sql.*;
import sun.jdbc.rowset.*;
public class CachedRowSetSerializer{
String fName = "ContactRowSet.ser";
public static void main(String[] argv){
CachedRowSetSerializer crs = new CachedRowSetSerializer();
crs.serializeRows();
Search WWH ::




Custom Search