Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

Supporting XML Data

SQL Server provides an xml data type that lets you store XML documents and fragments in a SQL Server database. The xml data type is a built-in data type in SQL Server, and is in some ways similar to other built-in types, such as int and varchar. Like other built-in types, you can use the xml data type as: a variable type, a parameter type, a function-return type, or a column type when you create a table; or in Transact-SQL CAST and CONVERT functions. In the JDBC driver, the xml data type can be mapped as a String, byte array, stream, CLOB, BLOB, or SQLXML object. String is the default mapping.

The JDBC driver provides support for the JDBC 4.0 API, which introduces the SQLXML interface. The SQLXML interface defines methods to interact with and manipulate XML data. The SQLXML is a JDBC 4.0 data type and it maps to the SQL Server xml data type. Therefore, in order to use the SQLXML data type in your applications, you must set the classpath to include the sqljdbc4.jar file. If the application tries to use the sqljdbc3.jar when accessing the SQLXML object and its methods, an exception is thrown.

Important note Important

SQL Server always validates the XML data before storing it in the database column. Applications can use SQLXML data type, because the JDBC driver maps it to the xml data type automatically. The SQLXML support is available in sqljdbc4.jar. See System Requirements for the JDBC Driver for the list of JRE versions supported by the Microsoft JDBC Driver for SQL Server.

The topics in this section describe the SQLXML interface and how to program against the SQLXML data type by using the JDBC API methods.

Topic

Description

SQLXML Interface

Describes the SQLXML interface and its methods.

Programming with SQLXML

Describes how to use the Microsoft JDBC Driver for SQL Server API methods to store and retrieve an XML data in and from a relational database with the SQLXML Java data type. Also contains information about the types of SQLXML objects and provides a list of important guidelines and limitations when using SQLXML objects.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.