HowTo Use Oracle Database System with Jena2

What is Oracle?

Oracle is one of the leading, commercially-available SQL relational database management systems. It is available in a variety of configurations from small personal versions to fault-tolerant, enterprise-class versions. It runs on a variety of hardware/operating system platforms.

Download and Installation of Oracle

As Oracle is commercially-available software, we cannot provide generic download instructions. We assume that Jena users wishing to use Oracle have access to an existing Oracle installation or access to the software. Below we list some assumptions and post-installation instructions for using Oracle with Jena.

Jena2 can be run with Oracle XE, as well as the full commercial versions, on both WindowsXP and Linux.

Jena2 can be run with both thin and thick JDBC drivers.

Currently, some configuration is necessary to work with all driver choices.

Connecting Your Jena Program to Oracle

Jena supports both memory models and database models. In general, a Jena program may use both types of models identically. However, there are some differences in how the models are created. Creating a memory model can be done with a single Jena call. Creating a database model, or opening a previously created one, requires several steps as as follows.

Important

Persistent models are created in the same way for any database system:

  1. Load the JDBC driver. This enables the Jena program to communicate with the database instance.
  2. Create a database connection. This creates a Java object for a database connection.
  3. Create a ModelMaker for the database
  4. Create a Model for existing or new data.

These steps are illustrated in the following Java code.

String className = "oracle.jdbc.driver.DriverOracle";   // path of driver class
Class.forName (className);                              // Load the Driver
String DB_URL =     "jdbc:oracle:oci:@";                // URL of database 
String DB_USER =   "????";                              // database user id
String DB_PASSWD = "????";                              // database password
String DB =        "Oracle";                            // database type

// Create database connection
IDBConnection conn = new DBConnection ( URL, DB_USER, DB_PASSWD, DB );
ModelMaker maker = ModelFactory.createModelRDBMaker(conn)

// create or open the default model
Model model = maker.createModel();

// Close the database connection
conn.close();

Notes

  1. We encountered problems with BLOBs when using the Oracle 9 and the thin driver to access an Oracle database running on the Linux operating system, so we recommend use of the oci driver when using Linux.
  2. Under Linux and Oracle 9, in running the database TestPackage, we get a Java warning that an SQLException was thrown when a thread attempts a next operation on a database iterator over a closed database connection. This appears to be a timing problem involving interaction with a finalize routine. The test returns the correct result. The warning does not occur under WindowsXP.

Oracle 10, including Oracle 10 XE, does not present these issues.