JDBC 4.0 spec lead Lance Andersen discusses how a new JDBC feature, the SQLXML interface, provides methods for accessing the XML data in a datasource as a String, a Reader, a Writer, or as a Stream.
Lance Andersen, spec lead for JDBC 4, comments that,
The JDBC EG has reworked the SQLXML interface completely providing for more flexibility. The new version of the interface will be available in the Java SE 6 upcoming beta and should also be available in the current nightly builds.
As an earlier Artima article about JDBC 4 noted, the JDBC 4 XML features are part of a goal to bring JDBC in line with the SQL 2003 standard (PDF) that offers an xml database data type. In a database that supports SQL 2003, you could create a table such as this:
Here getSource() returns a source used as input to XML parsers and XSLT transformers. JDBC 4 currently supports javax.xml.transform.dom.DOMSource, javax.xml.transform.sax.SAXSource, javax.xml.transform.stax.StAXSource, and javax.xml.transform.stream.StreamSource as possible class values.
As database vendors gradually adopt SQL 2003 in their products, most database servers will support XML natively. To what extent will wide XML support at the database level impact your application design?
For instance, would you prefer to use an object to model a blog entry and persist that object through an O/R tool in a more traditional, flattened database table, or would you rather write that object into an XML representation and save that XML in the database? What will be your use-cases for using XML natively in the database?