The JDBCXML Class

The JDBCXML class contains two static methods: the toXMLString method, which takes a JDBC ResultSet object and converts it to an XML document in string form, and the toXMLFile method, which takes a ResultSet object and a Writer object and converts the ResultSet to an XML document, which is then written to the file output. The code for this class is shown below.

The toXMLString method takes the ResultSet argument and obtains a ResultSetMetaData object to gather information about the ResultSet, such as the number of columns in the ResultSet and the names of the columns. It creates a StringBuffer to hold the contents of the XML document.

A loop is started to iterate through the contents of the ResultSet. As long as the ResultSet ...

Get J2EE™ and Beyond: Design, Develop, and Deploy World-Class Java™ Software now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.