Xml Column Updates In Sqlj Applications - IBM DB2 Manual

Table of Contents

Advertisement

In applications, XML data is in the serialized string format.
In SQLJ applications, you can:
v Store an entire XML document in an XML column using INSERT or UPDATE
v Retrieve an entire XML document from an XML column using single-row
v Retrieve a sequence from a document in an XML column by using the SQL
JDBC 4.0 java.sql.SQLXML objects can be used to retrieve and update data in XML
columns. Invocations of metadata methods, such as
ResultSetMetaData.getColumnTypeName return the integer value
java.sql.Types.SQLXML for an XML column type.

XML column updates in SQLJ applications

When you update or insert data into XML columns of a table in an SQLJ
application, the input data must be in the serialized string format.
The host expression data types that you can use to update XML columns are:
v java.sql.SQLXML (requires an SDK for Java Version 6 or later, and the IBM Data
v com.ibm.db2.jcc.DB2Xml (deprecated)
v String
v byte
v Blob
v Clob
v sqlj.runtime.AsciiStream
v sqlj.runtime.BinaryStream
v sqlj.runtime.CharacterStream
For stream types, you need to use an sqlj.runtime.typeStream host expression,
rather than a java.io.typeInputStream host expression so that you can pass the
length of the stream to the JDBC driver.
The encoding of XML data can be derived from the data itself, which is known as
internally encoded data, or from external sources, which is known as externally
encoded data. XML data that is sent to the database server as binary data is treated
as internally encoded data. XML data that is sent to the data source as character
data is treated as externally encoded data. The external encoding is the default
encoding for the JVM.
External encoding for Java applications is always Unicode encoding.
Externally encoded data can have internal encoding. That is, the data might be sent
to the data source as character data, but the data contains encoding information.
The data source handles incompatibilities between internal and external encoding
as follows:
146
Application Programming Guide and Reference for Java
statements.
SELECT statements or iterators.
XMLQUERY function to retrieve the sequence in the database, and then using
single-row SELECT statements or iterators to retrieve the serialized XML string
data into an application variable.
Related concepts
"XML column updates in SQLJ applications"
"XML data retrieval in SQLJ applications" on page 148
Server Driver for JDBC and SQLJ version 4.0 or later)

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents