EasyManuals Logo

IBM DB2 User Manual

IBM DB2
585 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #81 background imageLoading...
Page #81 background image
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
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.
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.
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
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 Input data type
PreparedStatement.setAsciiStream InputStream
PreparedStatement.setBinaryStream InputStream
PreparedStatement.setBlob Blob
PreparedStatement.setBytes byte[]
PreparedStatement.setCharacterStream Reader
PreparedStatement.setClob Clob
PreparedStatement.setObject byte[], Blob, Clob, SQLXML, DB2Xml (deprecated), InputStream,
Reader, String
PreparedStatement.setString String
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
Chapter 3. JDBC application programming 65

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the IBM DB2 and is the answer not in the manual?

IBM DB2 Specifications

General IconGeneral
DeveloperIBM
Initial Release1983
LicenseProprietary
Written inC, C++
CategoryDatabase Management System (RDBMS)
Operating SystemLinux, Windows
Programming LanguagesC, C++
Data ModelsRelational
EditionsCommunity, Standard, Advanced
Key Featureshigh availability, scalability