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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access