ResultSet documents consist of ResultSetMetaData followed by ResultSetData, as shown in the following general form:
<?xml version="1.0"?> <!DOCTYPE ResultSet SYSTEM 'ResultSet.dtd'> <ResultSet>
<ResultSetMetaData> … </ResultSetMetaData>
<ResultSetData> … </ResultSetData>
</ResultSet>
The ResultSetMetaData portion of an XML ResultSet consists of the SQL metadata returned by the methods of the JDBC ResultSet class. The ResultSetMetaData for the example result set is:
<ResultSetMetaData getColumnCount="7">
<ColumnMetaData getColumnDisplaySize="25" getColumnLabel="Date" getColumnName="Date" getColumnType="93" getPrecision="0" getScale="0" isAutoIncrement="false" isCurrency="false" isDefinitelyWritable="false" isNullable="false" isSigned="false" />
<ColumnMetaData getColumnDisplaySize="5" getColumnLabel="CustomerId" getColumnName="CustomerId" getColumnType="12" getPrecision="0" getScale="0" isAutoIncrement="false" isCurrency="false" isDefinitelyWritable="false" isNullable="false" isSigned="false" />
<ColumnMetaData getColumnDisplaySize="50" getColumnLabel="CustomerName" getColumnName="CustomerName" getColumnType="12" getPrecision="0" getScale="0" isAutoIncrement="false" isCurrency="false" isDefinitelyWritable="false" isNullable="false" isSigned="false" />
<ColumnMetaData getColumnDisplaySize="5" getColumnLabel="ItemId" getColumnName="ItemId" getColumnType="12" getPrecision="0" getScale="0" isAutoIncrement="false" isCurrency="false" isDefinitelyWritable="false" isNullable="false" isSigned="false" />
<ColumnMetaData getColumnDisplaySize="20" getColumnLabel="ItemName" getColumnName="ItemName" getColumnType="12" getPrecision="0" getScale="0" isAutoIncrement="false" isCurrency="false" isDefinitelyWritable="false" isNullable="false" isSigned="false" />
<ColumnMetaData getColumnDisplaySize="11" getColumnLabel="Quantity" getColumnName="Quantity" getColumnType="4" getPrecision="0" getScale="0" isAutoIncrement="false" isCurrency="false" isDefinitelyWritable="false" isNullable="false" isSigned="true" />
<ColumnMetaData getColumnDisplaySize="6" getColumnLabel="unit" getColumnName="unit" getColumnType="5" getPrecision="0" getScale="0" isAutoIncrement="false" isCurrency="false" isDefinitelyWritable="false" isNullable="false" isSigned="true" />
</ResultSetMetaData>
The names of the attributes of ColumnMetaData are simply the names of the methods of the JDBC ResultSetMetaData class, and the values of those attributes are the values returned by those methods.
The ResultSetData portion of an XML ResultSet document is a list of Row elements, each having a list of Column elements. The text value of a Column element is the value returned by the JDBC getString( ) method for the column. The ResultSetData for the example is:
<ResultSetData> <Row> <Column name="Date">1999-07-04 00:00:00.0</Column> <Column name="CustomerId">123</Column> <Column name="CustomerName">Acme Alpha</Column> <Column name="ItemId">987</Column> <Column name="ItemName">Coupler</Column> <Column name="Quantity">5</Column> <Column name="unit">1</Column> </Row> <Row> <Column name="Date">1999-07-04 00:00:00.0</Column> <Column name="CustomerId">123</Column> <Column name="CustomerName">Acme Alpha</Column> <Column name="ItemId">654</Column> <Column name="ItemName">Connecter</Column> <Column name="Quantity">3</Column> <Column name="unit">12</Column> </Row> <Row> <Column name="Date">1999-07-04 00:00:00.0</Column> <Column name="CustomerId">123</Column> <Column name="CustomerName">Acme Alpha</Column> <Column name="ItemId">579</Column> <Column name="ItemName">Clasp</Column> <Column name="Quantity">1</Column> <Column name="unit">1</Column> </Row> </ResultSetData> </ResultSet>