UnityJDBC requires information about the data sources being queried in order to
validate, optimize, and execute queries against those data sources. All source information
is stored in XML files. There are two types of source information files: the
sources file and schema files. A
sources file with default name sources.xml
provides information on all the sources that could be potentially queried. The location of
this file is provided via the URL when initializing the driver. Inside the file is
information on each source including its connection URL and parameters, JDBC driver, and
schema file location. The sample sources file
code\test\xspec\UnityDemo.xml
is provided in the distribution
package. Each data source requires a schema file. The schema file is an
XML encoding of the schema information including table and field names, keys, joins, and
relation sizes. It is used for validating queries and optimization. Two schema files
provided in the distribution are: code\test\xspec\UnityDemoOrder.xml
and code\test\xspec\UnityDemoPart.xml
.
There are two ways to create your own sources file and associated schema files:
The easiest way is to use the SourceBuilder GUI that can be started using the
installed shortcut or running initsources.bat
or
initsources.sh
. This GUI will automatically extract source
information and build the necessary files. If you are using UnityJDBC as the multisource
plugin in SQuirreL SQL, all features of the SourceBuilder are integrated into SQuirreL,
and the XML files are generated automatically.
You can manually build a sources file using a text editor. To produce a schema file
for a source, open up the program called
com/unityjdbc/SourceBuilder/SchemaExtractor.java
in the
code
directory. Modify the JDBC URL, driver path, and output
directory accordingly and run the program. The account that you connect with must have
read access to the database and associated tables that you want to access. After the XML
schema file has been produced, move it to the directory where you want it and update the
sources file to reference the correct location. In almost all cases, using the
SourceBuilder utility will be faster and easier.