Data returned by many of the java.sql classes are contained within a ResultSet object. In Host Integrator, all ResultSet objects contain static data. That is, the data that is fetched from the Host Integrator Server is stored in a ResultSet object, but once fetched there is no connection maintained to the server from within the ResultSet. This means that the only methods that are implemented in the ResultSet are concerned with accessing the data within the ResultSet.Conversely, methods that update or modify the ResultSet object are not implemented. From a JDBC terminology perspective, these facts mean that Host Integrator ResultSets are CONCUR_READ_ONLY rather than CONCUR_UPDATEABLE.
A ResultSet object in Host Integrator is always of type TYPE_SCROLL_INSENSITIVE. This means that the result set is scrollable: i.e. its cursor can move forward or backward and can be moved to a particular row or to a row whose position is relative to the current cursor position. As described above, however, the result set does not reflect changes made to the underlying host application. That is, the data in a ResultSet object are static - fixed at the time the ResultSet object was created.
The following example is a Java method that sequences through a Host Integrator result set returned from a SQL SELECT statement and prints each row in the ResultSet to the standard output stream.
void processRS(ResultSet rs) throws Exception { // First, get the list of columns from ResultSetMetaData ResultSetMetaData rsMd = rs.getMetaData(); ArrayList outputColumns = new ArrayList(); int cols = rsMd.getColumnCount(); for(int i = 1; i <= cols; i++) { String colName = rsMd.getColumnName(i); outputColumns.add(colName); } // Now sequence through all of the rows in the ResultSet int rowIndex=1; while(rs.next()) { String rowData = new String("Row "+rowIndex+": "); Iterator it = outputColumns.iterator(); while(it.hasNext()) { String col = (String)it.next(); rowData += col+"="+rs.getString(col)+" "; } // Print the row string System.out.println(rowData); rowIndex++; } }
© 1999-2007 Attachmate Corporation. All rights reserved. Terms of Use.