v Use the ResultSet.getObject method to retrieve the data, and then cast it to the
DB2Xml type and assign it to a DB2Xml object. Then use a DB2Xml.getDB2XXX or
DB2Xml.getDB2XmlXXX method to retrieve the data into a compatible output data
type.
DB2Xml.getDB2XmlXXX methods add XML declarations with encoding
specifications to the output data. DB2Xml.getDB2XXX methods do not add XML
declarations with encoding specifications to the output data.
This technique uses the deprecated DB2Xml objects. Use of the previously
described technique is preferable.
The following table lists the ResultSet methods and corresponding output data
types for retrieving XML data.
Table 15. ResultSet methods and data types for retrieving XML data
Method Output data type
ResultSet.getAsciiStream InputStream
ResultSet.getBinaryStream InputStream
ResultSet.getBytes byte[]
ResultSet.getCharacterStream Reader
ResultSet.getObject DB2Xml
ResultSet.getSQLXML SQLXML
ResultSet.getString String
The following table lists the methods that you can call to retrieve data from a
java.sql.SQLXML or a com.ibm.db2.jcc.DB2Xml object, and the corresponding
output data types and type of encoding in the XML declarations.
Table 16. SQLXML and DB2Xml methods, data types, and added encoding specifications
Method Output data type Type of XML internal encoding declaration added
SQLXML.getBinaryStream InputStream None
SQLXML.getCharacterStream Reader None
SQLXML.getSource Source None
SQLXML.getString String None
DB2Xml.getDB2AsciiStream InputStream None
DB2Xml.getDB2BinaryStream InputStream None
DB2Xml.getDB2Bytes byte[] None
DB2Xml.getDB2CharacterStream Reader None
DB2Xml.getDB2String String None
DB2Xml.getDB2XmlAsciiStream InputStream US-ASCII
DB2Xml.getDB2XmlBinaryStream InputStream Specified by getDB2XmlBinaryStream targetEncoding
parameter
DB2Xml.getDB2XmlBytes byte[] Specified by DB2Xml.getDB2XmlBytes targetEncoding
parameter
DB2Xml.getDB2XmlCharacterStream Reader ISO-10646-UCS-2
DB2Xml.getDB2XmlString String ISO-10646-UCS-2
68 Application Programming Guide and Reference for Java
â„¢