Updating Relational Data with XQuery™ 3.0 and JDBC

Businesses integrating XML and relational data often need to update their relational data using XML input. Most technologies that process XML information in Java™, such as DOM and SAX, are cumbersome to implement. XQuery is ideal for querying and restructuring both XML and relational data, but XQuery updates are still in the planning stage. Using a combination of DataDirect XQuery, which is DataDirect's implementation of XQuery for Java API (XQJ), and JDBC offers a simple solution to working with both XML and relational data, and providing updates to relational data.

This article presents two example applications, including source code, that show how to use DataDirect XQuery and JDBC to update data in environments that integrate XML and relational data.

Scenario: Updating Relational Data from XML Messages

Before we introduce our example applications, let's describe the type of scenario our applications are designed to solve. Suppose a company allows its customers to update their current account information over the Internet.

Learn More

Example 1: Using XQuery Result Sequences and JDBC Prepared Statements

For each customer element, this application accesses the custinfo table and customer child elements using an XQuery query. Then, the application determines whether the current customer element triggers an insert, update, or delete of the custinfo table.

Learn More

Example 2: Using Java External Functions and JDBC Prepared Statements

In contrast to our first example application, this application uses DataDirect XQuery Java external functions to pass the appropriate update action and related data extracted from the XML message from the XQuery query to the Java application.

Learn More