Sam Eldin
Web Services New Tool®
Project Tool
- Demo
Home Data Objects Reflection & DOM XML Fields Database Tables Reflection & JAXP Utilities
XML Fields - Executive Summary
XML Fields:
Our tool converts Java beans to XML Report which is stored in a database field. Such field is the target of all database SQL calls. Therefore we need to present what this database field is as well as how to use it. The following are a list of quick tutorial as well some of the important processes that our tool will perform:
CLOB
XML Data Type
Java code processing CLOB and XML Field
SQL code processing CLOB and XML Field
Database Services Using CLOB and XML Field

CLOB
What is CLOB?
A Character Large Object (or CLOB) is a collection of character data in a database management system, usually stored in a separate location that is referenced in the table itself. Oracle and IBM DB2 provide a construct explicitly named CLOB, and the majority of other database systems support some form of the concept, often labeled as text, memo or long character fields.
CLOBs usually have very high size limits, on the order of 2GB or more. The tradeoff for the capacity is usually limited access methods. In particular, some database systems limit certain SQL clauses, such as LIKE or SUBSTRING from being used on CLOBs.
Database systems vary in their storage patterns for CLOBs. Some systems always store CLOBs as a reference to out-of-table data, while others store small CLOBs in-table, changing their storage patterns when the size of the data grows beyond a threshold. Other systems are configurable in their behavior.
Java.sql interface Clob is the mapping in the JavaTM programming language for the SQL CLOB type. An SQL CLOB is a built-in type that stores a Character Large Object as a column value in a row of a database table. By default drivers implement a Clob object using an SQL locator(CLOB), which means that a Clob object contains a logical pointer to the SQL CLOB data rather than the data itself. A Clob object is valid for the duration of the transaction in which it was created.
The Clob interface provides methods for getting the length of an SQL CLOB (Character Large Object) value, for materializing a CLOB value on the client, and for searching for a substring or CLOB object within a CLOB value. Methods in the interfaces ResultSet, CallableStatement, and PreparedStatement, such as getClob and setClob allow a programmer to access an SQL CLOB value. In addition, this interface has methods for updating a CLOB value.

In short CLOB is a database field that stores text. The reason for presenting CLOB is the fact that not all databases support XML data type Field. Therefore, our tool should also handle the CLOB.

XML Data Type - Microsoft
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. As with other built-in types, you can use the xml data type as a column type when you create a table; as a variable type, a parameter type, or a function-return type; 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. Starting with the JDBC Driver version 2.0, the JDBC driver provides support for the JDBC 4.0 API, which introduces the SQLXML interface. The SQLXML interface defines methods to interact and manipulate XML data. The SQLXML data type maps to the SQL Server xml data type. For more information about how to read and write XML data from and to the relational database with the SQLXML Java data type, see Supporting XML Data.

XML Data Type - Oracle
Storing XML in the Oracle database, since Oracle 9iR1, you can store XML in the database as a separate datatype: XMLType. There are 2 ways to store data in XMLType:

          Store XML in CLOB XMLType (from Oracle 9iR1)
          Store XML as structured data.

Register an XML Schema and store XML in an XML-schema based XMLType using Object-relational storage (from Oracle 9iR2). Host variable data types for XML data in embedded SQL applications

XML Data Type - IBM
The XML host variable types are compatible only with the XML column data type. You can use BLOB, CLOB, DBCLOB, CHAR, VARCHAR, GRAPHIC, VARGRAPHIC, BINARY, or VARBINARY host variables to update XML columns. You can convert the host variable data types to the XML type using the XMLPARSE function, or you can let the DB2 database server perform the conversion implicitly.

Java Code Processing CLOB and XML Field
Patience is a Virtue:


SQL Code Processing CLOB and XML Field
Patience is a Virtue:

Database Services Using CLOB and XML Field
Patience is a Virtue: