Query any IBM DB2 database with XQuery through the Stylus XQuery XQJ API. Only the JDBC URL changes across vendors — the XQJ code below is identical for every supported database.
jdbc:xquery:db2://host:50000;databaseName=your_database
For DB2 on z/OS or iSeries, use locationName=db2_location
in place of databaseName.
import javax.xml.xquery.*;
import java.util.Properties;
import com.ddtek.xquery.xqj.DDXQDataSource;
public class Db2Example {
public static void main(String[] args) throws XQException {
DDXQDataSource ds = new DDXQDataSource();
ds.setProperty(DDXQDataSource.JDBCURL,
"jdbc:xquery:db2://server1:50000;databaseName=SAMPLE;User=db2admin;Password=secret");
XQConnection cn = ds.getConnection();
XQPreparedExpression q = cn.prepareExpression(
"for $c in fn:collection('customers')/* return <name>{$c/CompanyName/text()}</name>");
System.out.println(q.executeQuery().getSequenceAsString(new Properties()));
cn.close();
}
}
| Test family | Status |
|---|---|
| SQL data-type coverage (BIGINT, DECIMAL, TIMESTAMP, VARCHAR, CLOB, XML, …) | ✔ |
| Relational use cases — query & join pushdown | ✔ |
| XQuery Functions & Operators library | ✔ |
| XQuery Update Facility (XUF) | ✔ |
| Modules & prolog | ✔ |
| Namespaces | ✔ |
| Internationalization & encodings | ✔ |
| Regression & customer defects | ✔ |