Featured Database Articles

Converting JDBC Result Sets to XML

XML has become the common format for passing data between components residing on different platforms. With the move to XML-based services, developers often find themselves converting various data structures to and from XML. Arguably, the most prevalent form of persisting data is in relational databases. How does one go about converting relational data structures into XML? In this article, we'll do just that and build a utility to expose relational data as XML documents.

I'll focus on this problem from a Java programmer's perspective, although the concepts here could be implemented in other languages as well. JDBC (Java Data Base Connectivity) provides a common API for accessing a multitude of relational databases. It provides all the methods we need to create our result-set-to-XML utility.