|
YOUR FEEDBACK
Did you read today's front page stories & breaking news?
SYS-CON.TV |
TOP THREE LINKS YOU MUST CLICK ON Industry Commentary JDBC 4.0: A Significant Advance on the Standard and Features Worth the Wait
A significant advance on the standard
By: John Goodson
Jul. 27, 2005 07:45 AM
Pooling is great - except it's not very tunable, it's hard to map end users back to connections in the pool, and if a connection ever becomes invalid inside the pool, expunging only that connection from the pool is nearly impossible; JDBC 4.0 addresses all these drawbacks
The JDBC 4.0 specification is now in public review and will ship as part of J2SE 6.0 sometime in 2006. The key goals of the JDBC Expert Group were to align with the most important features of the SQL 2003 specification, provide constructs that help improve developer productivity (sometimes called Ease of Development or EOD features), fine tune pooling constructs, and improve scalability. Unlike the JDBC 3.0 specification, there are some major new additions in the JDBC 4.0 spec, such as XML support. Overall, it's not just a collection of bug fixes to the JDBC 3.0 specification; JDBC 4.0 is clearly a significant advance of the standard. XML Support A new SQL data type, SQLXML, is part of the specification. Applications can use getTypeInfo() to determine if their database supports a native XML data type. For example, getTypeInfo() against a SQL Server 2000 instance doesn't return a result row corresponding to the SQLXML data type, indicating that there's no native XML data type available for that particular database backend. By contrast, getTypeInfo() against a SQL Server 2005 instance returns a result row, indicating that an XML data type is available. It also returns information indicating that the native type name is "XML." From this information, applications can create tables that contain columns of the XML data type. So applications can populate data in XML columns and retrieve data from those columns, JDBC has been expanded to include native Java bindings for XML. Initially, the Expert Group looked at adding all types of XML bindings, such as text, JAXP, DOM, JDOM, SAX, stream, and StAX. In the end, allowing so many different bindings had too many drawbacks. The Expert Group decided to allow bindings for Java strings, Java character streams, and StAX. If an application needs to process data inside DOM or SAX, for example, it's a straightforward exercise to convert that data from a StAX stream to those representations. To create a Java construct that can be used to process XML data, an application can create a SQLXML object off of the Connection object using the createSQLXML() method. The object that's created doesn't contain any data initially. Data can be added to the object by calling setString() or associating an XML stream using createXMLStreamWriter() with the object. The following code illustrates how an application can use these techniques to insert a row containing XML data into a table. Similarly, applications can retrieve a string representation of the XML using the getString() method of the object or by associating an XML stream using createXMLStreamReader(). The following code illustrates how an application can SELECT a column of the SQLXML data type, create a SQLXML Java binding using getSQLXML() on the result set, and read the value into the new object using a StAX representation via createXMLStreamReader(). LATEST JAVA STORIES & POSTS
SUBSCRIBE TO THE WORLD'S MOST POWERFUL NEWSLETTERS SUBSCRIBE TO OUR RSS FEEDS & GET YOUR SYS-CON NEWS LIVE!
|
SYS-CON FEATURED WHITEPAPERS MOST READ THIS WEEK SPONSORED BY INFRAGISTICS
BREAKING JAVA NEWS
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||