The XML data type is used:
- To store XML documents that conform to the SQL/XML definition of a well-formed
XML(DOCUMENT(ANY)) value.
- Transiently, for XML(SEQUENCE) values that might not be well-formed
XML(DOCUMENT(ANY)) values.
Because none of the
JDBC-side support for SQL/XML is implemented in ,
it is not possible to bind directly into an XML value or to retrieve an XML
value directly from a result set using JDBC. Instead, you must bind and retrieve
the XML data as Java strings or character streams by explicitly specifying
the appropriate XML operators,
XMLPARSE and
XMLSERIALIZE, as part of your SQL
queries.
JDBC metadata type (java.sql.Types)None.
The
metadata type for XML values is SQLXML. However, the SQLXML type is not supported
by .
To retrieve
XML values from a database
using JDBC, use the XMLSERIALIZE operator in the SQL query. For example:
SELECT XMLSERIALIZE (xcol as CLOB) FROM myXmlTable
Then retrieve the XML value by using the getXXX method that corresponds
to the target serialization type, in this example CLOB data types.
To store
an XML value into a database
using JDBC, use the XMLPARSE operator in the SQL statement. For example:
INSERT INTO myXmlTable(xcol) VALUES XMLPARSE(
DOCUMENT CAST (? AS CLOB) PRESERVE WHITESPACE)
Then use any of the setXXX methods that are compatible with String
types. In this example, use the PreparedStatement.setString or
PreparedStatement.setCharacterStream method calls to bind the
operator.
See "XML data types and operators" in the
for more information.