Blog
DB2utor

Categories

February 24, 2009

A Tip on XML Schema Registration

Enforcing or validating XML documents against an XML schema is one concern DBAs have when storing XML documents in DB2. An XML schema contains a description of the corresponding XML document, along with constraints on the document's structure and contents.

DB2 9 for z/OS provides XML validation management through the XML schema repository (XSR). Once you add your schema to XSR, you can use it to validate XML documents before storing them in the XML column.

The XML schema registration can be handled manually through one of these methods:

  • Call the following DB2 stored procedures:sysproc.xsr_register, sysproc.xsr_addschemadoc, sysproc.xsr_complete
  • Invoke the following JDBC method that performs all the stored procedure steps: com.ibm.db2.jcc.DB2Connection.registerDB2XmlSchema
  • Invoke the following commands from command line processor: –REGISTER XMLSCHEMA, -ADD XMLSCHEMA DOCUMENT, -COMPLETE XMLSCHEMA


I was happy to learn that I didn't have to write a program to call the stored procedures or invoke the JDBC methods. IBM delivered Data Studio Developer for free to handle this process for you.

I mention this because I want to help you avoid the pitfall that I fell into when I tried to get the Data Studio XML schema registration process to work with DB2 V9 for z/OS. First, if you're installing DB2 and JDBC support, read the DB2 Version 9.1 for z/OS Application Programming Guide and Reference for Java. This guide provides all the steps necessary to install JDBC support on z/OS. 

My problem was that I received an SQLCODE -805 on the SYSSTAT package. When I checked SYSIBM.SYSPACKAGE, I found SYSTAT with the default collection ID of NULLID. After searching, I found the error message in the WLM address space. The stored procedure was trying to find the package in the SYSXSR collection. I've not found any documentation stating that JDBC drivers must be installed with collection ID SYSXSR. Since I'm not aware of a way to change the collection Data Studio uses, the solution is to install the drivers in the SYSXSR collection.

To install the drivers, modify the DB2Binder parameters "collection" as I have here:

java com.ibm.db2.jcc.DB2Binder -url jdbc:db2://192.87.15.123:496/DB9GLOC
  -user sysadm -password db2rocks -collection SYSXSR