Powered by SmartDoc

JDBC Importer

The JDBC importer reads an RDBMS schema via JDBC. If the suffix for an argument is rjdbc, Relaxer uses the JDBC importer.

RJDBC

A schema for an rjdbc file is shown in List 4.4.1.1[rjdbc.rng]. A uri element and a table element are always needed. A username element, a password element, a driver element and a classpath element are all optional.

rjdbc.rng
<?xml version="1.0" encoding="UTF-8" ?>
<grammar xmlns="http://relaxng.org/ns/structure/1.0">
  <start>
    <ref name="rjdbc"/>
  </start>
  <define name="rjdbc">
    <element name="rjdbc">
      <element name="uri">
        <text/>
      </element>
      <element name="table">
        <text/>
      </element>
      <optional>
        <element name="username">
          <text/>
        </element>
      </optional>
      <optional>
        <element name="password">
          <text/>
        </element>
      </optional>
      <optional>
        <element name="driver">
          <text/>
        </element>
      </optional>
      <optional>
        <element name="classpath">
          <list>
            <oneOrMore>
              <text/>
            </oneOrMore>
          </list>
        </element>
      </optional>
    </element>
  </define>
</grammar>

Example

List 4.4.2.1[hello.rjdbc] is a sample rjdbc file. This configuration indicates the following:

hello.rjdbc
<rjdbc>
  <uri>jdbc:superdb:helloDb</uri>
  <table>hello</table>
  <username>XML Taro</username>
  <password>iea2x32</password>
  <driver>org.superdb.jdbc.superDriver</driver>
  <classpath>superdb.jar j2ee.jar</classpath>
</rjdbc>
$ relaxer -jdbc hello.rjdbc

As a result, Java objects to access the RDMBS table specified by hello.rjdbc.