Xml Data In Jdbc Applications; Xml Column Updates In Jdbc Applications - IBM DB2 Manual

Table of Contents

Advertisement

XML data in JDBC applications

In JDBC applications, you can store data in XML columns and retrieve data from
XML columns.
In database tables, the XML built-in data type is used to store XML data in a
column as a structured set of nodes in a tree format.
In applications, XML data is in the serialized string format.
In JDBC applications, you can:
v Store an entire XML document in an XML column using setXXX methods.
v Retrieve an entire XML document from an XML column using getXXX methods.
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 JDBC applications

When you update or insert data into XML columns of a database table, the input
data in your JDBC applications must be in the serialized string format.
The following table lists the methods and corresponding input data types that you
can use to put data in XML columns.
Table 14. Methods and data types for updating XML columns
Method
PreparedStatement.setAsciiStream
PreparedStatement.setBinaryStream
PreparedStatement.setBlob
PreparedStatement.setBytes
PreparedStatement.setCharacterStream
PreparedStatement.setClob
PreparedStatement.setObject
PreparedStatement.setString
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
XMLQUERY function to retrieve the sequence into a serialized sequence in the
database, and then using getXXX methods to retrieve the data into an application
variable.
Related concepts
"XML column updates in JDBC applications"
"XML data retrieval in JDBC applications" on page 67
Related reference
"Data types that map to database data types in Java applications" on page 193
Input data type
InputStream
InputStream
Blob
byte[]
Reader
Clob
byte[], Blob, Clob, SQLXML, DB2Xml (deprecated), InputStream,
Reader, String
String
Chapter 3. JDBC application programming
65

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents