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.
JDBC applications can send XML data to the data server or retrieve
XML data from the data server in one of the following forms:
- As textual XML data
- As binary XML data, if the data server supports it
In JDBC applications, you can:
- Store an entire XML document in an XML column using setXXX methods.
- Retrieve an entire XML document from an XML column using getXXX methods.
- 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.
- Retrieve a sequence from a document in an XML column
by using an XQuery expression, prepended with the string 'XQUERY',
to retrieve the elements of the sequence into a result table in the
database, in which each row of the result table represents an item
in the sequence. Then use getXXX methods to retrieve
the data into application variables.
- Retrieve a sequence from a document in an XML column as a user-defined
table by using the SQL XMLTABLE function to define the result table
and retrieve it. Then use getXXX methods to retrieve
the data from the result table into application variables.
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.