Java Reference
In-Depth Information
rowSet.execute();
// read the data and put it to the console
while (rowSet.next()){
for(int j=1; j<=rowSet.getMetaData().getColumnCount(); j++){
System.out.print( rowSet.getObject(j)+"\t");
}
System.out.println();
}
rowSet.close();
} catch(Exception e) {
e.printStackTrace();
}
}
}
The results of the JDBCRowSetExample of Listing 18-1 returns are shown in Table 18-1 .
Table 18-1: Results the JDBCRowSetExample Returns
ID
FName
LName
EMail
2001
Oliver
Dewey
o.dewey@dsh.com
2002
Ichabod
Cheatham
i.cheatham@dsh.com
2003
Anne
Howe
a.howe@dsh.com
Making a RowSet Scrollable and Updatable
Among the enhancements of the JDBC Extension API was the ability to make ResultSets scrollable
and updatable. The same capabilities can be added to a RowSet by setting the appropriate properties.
Listing 18-2 shows how simply the RowSet created in Listing 18-1 can be made scrollable.
Listing 18-2: Making a RowSet scrollable
package JavaDatabaseBible.ch18;
import java.sql.*;
import com.inet.tds.JDBCRowSet;
public class JDBCRowSetExample{
public static void main(String[] argv){
String url = "jdbc:inetdae7:localhost:1433?database=LEDES";
String login = "jod";
String password = "jod";
try {
Search WWH ::




Custom Search