Book Image

JDBC 4.0 and Oracle JDeveloper for J2EE Development

Book Image

JDBC 4.0 and Oracle JDeveloper for J2EE Development

Overview of this book

Table of Contents (20 chapters)
JDBC 4.0 and Oracle JDeveloper for J2EE Development
Credits
About the Author
About the Reviewer
Preface

SQL Database to XML Document Mapping


We will map the database table JOURNAL to an XML document, using the XML SQL Utility. The OracleXMLQuery class is used to convert a database table to an XML document. In the generated XML document, an XML element gets created corresponding to each of the database table columns. Element attributes do not get created, and to create them apply an XSLT to the XML document that was created from the database table with the OracleXMLQuery class.

The procedure to create an XML document with elements and element attributes is discussed in this section. Import the OracleXMLQuery class and create an OracleXMLQuery class object:

OracleXMLQuery query = new OracleXMLQuery(conn, "SELECT CATALOGID, JOURNAL_TITLE, PUBLISHER, EDITION, ARTICLE_SECTION, TITLE, AUTHOR FROM JOURNAL");

Variable conn is the JDBC connection used to query the database. The SELECT SQL statement specifies the query to select data from the database table, JOURNAL. Apply an XSLT to the OracleXMLQuery...