Home Services Partners Company
XQuery debut for Java Platform

XQuery debut for Java Platform

May 16, 2005 0 Comments

XQuery comes to the Java platform with the launch of the DataDirect XQuery™ beta program starting tomorrow on May 17th. With this important technology boundary crossed, I thought it was well overdue for some code snippets in my blogs. I think this is a habit I should develop a little more.

Enabling your Java applications with XQuery is as easy as establishing a context to an XQuery data source with the following code.

1. First, import the appropriate packages

2. Next, establish a context to the XQuery data source.Fairly simple so far, as I'm sure you will agree. Remember, XQuery does not discriminate what data source it queries as long as it can viewed as XML. With DataDirect XQuery we provide support for connecting to an XML data source using URIs including

file://

or

http://

but we also enable XQuery expressions to be written against relational data stores. To describe the data sources to connect to, we provide a simple configuration file to allow you to describe the data source to connect to.

3. Next you apply the configuration file to the DDXQDataSource:

import com.ddtek.xquery.*
import com.ddtek.xquery.xqj.DDXQDataSource;
XQDataSource dataSource = null;
DDXQDataSource dataSource = (DDXQDataSource)new DDXQDataSource();
<?xml version="1.0"?>
<XQJConnection xmlns="http://www.datadirect.com/xquery">
<JDBCConnections>
<JDBCConnection prefix="my_oracle_config">
<description>My description of this particular configuration</description>
<url>jdbc:xquery:oracle://hostname_or_ip:1521;SID=orcl_sid_name</url>
<user>example_db_user</user>
<password>example_user_pw</password>
<sqlxmlMapping>
<forest>true</forest>
<identifierEscaping>full</identifierEscaping>
</sqlxmlMapping>
<catalog>
<schema name="example_db_user">
</schema>
</catalog>
</JDBCConnection>
</JDBCConnections>
</XQJConnection>
dataSource.setConfigFile(

Jonathan Bruce

View all posts from Jonathan Bruce on the Progress blog. Connect with us about all things application development and deployment, data integration and digital business.

Read next Tutorial: Data Gateway from DigitalOcean to On-Premises
Comments
Comments are disabled in preview mode.