Java Reference
In-Depth Information
if(rows==null){
initialise();
}
return absolute(1);
}
public boolean last() throws SQLException {
if(rows==null){
initialise();
}
return absolute(-1);
}
A more complete implementation of the scrollable ResultSet requires additional methods to report
the cursor position. It also requires a mechanism to handle requests for different ResultSet typessuch
as TYPE_FORWARD_ONLY or TYPE_SCROLL_SENSITIVE .
The XMLResultSetMetaData class
XMLResultSet is supported by XMLResultSetMetaData , an implementation of the interface
ResultSetMetaData . This provides such utility information as column counts, column names, column
data types, and so on. The code is shown in Listing 19-8 .
Listing 19-8: XMLResultSetMetaData class
package JavaDatabaseBible.ch19.JDBCforXML;
import java.sql.*;
import java.util.Vector;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import JavaDatabaseBible.ch19.JDBCImpl.JDBCResultSetMetaDataImpl;
public class XMLResultSetMetaData extends JDBCResultSetMetaDataImpl{
private XMLResultSet rs;
private NodeList rows = null;
private NodeList cols = null;
private Vector columnNameVector = new Vector();
public XMLResultSetMetaData(XMLResultSet rs){
this.rs = rs;
Element root = rs.xmlDoc.getDocumentElement();
rows = root.getChildNodes();
Element currentRow = (Element)rows.item(0);
Search WWH ::




Custom Search