O'Reilly logo

J2EE™ and Beyond: Design, Develop, and Deploy World-Class Java™ Software by Art Taylor

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required