Databases Reference
In-Depth Information
setCharacterStream()
setClob()
setBlob()
setObject()
Supports DB2Xml, String, byte[], inputStream, Reader, CLOB, and BLOB as
parameters
The encoding conversion of the XML data depends on which set XXX method is
used to bind the parameter value. The setAsciiStream, setCharacterStream, and
setString methods convert the encoding to UTF-8 and send the XML value as an
explicit external encoding; setByte and setBinaryStream assume that the internal
encoding is correct and send the XML value with internal encoding.
An XML value can be retrieved from the ResultSet using the following get XXX
methods:
getBytes()
getString()
getAsciiStream()
getBinaryStream()
getCharacterStream()
getObject()
The getObject method will retrieve the XML value as an DB2Xml class object.
The XML values retrieved by these methods are externally encoded data and
without explicit XML declaration. These methods cannot be called on the same
XML row again. Trying to do that will throw an SQLException.
com.ibm.db2.jcc.DB2Xml Class
DB2 Universal JDBC driver introduces the DB2Xml class. The object of this class
is returned to the application whenever the getObject method is used to retrieve
the XML column value from the ResultSet object.
This class define methods to convert the XML data to other Java data types,
such as String, byte[], BinaryStream, and AsciiStream. These methods have the
getDB2 XXX format where XXX indicate the data type. This class also defines the
methods which convert the XML data to the specified data and add the XML
declaration tag. These methods have a format such as getDB2Xml XXX .
Example 5-16 shows how to retrieve an XML value as a DB2Xml object.
Example 5-16 Retrieving XML value as a DB2Xml object
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery("select info from customer");
Search WWH ::




Custom Search