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 has been tested with the 10.2.0.x JDBC drivers which work for Oracle9i for 9.2.0.x, Oracle10g (10.2.0.x and 10.1.0.x).

Jena2 no longer requires specific Oracle configuration.

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.

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.OracleDriver";   // path of driver class
Class.forName (className);                              // Load the Driver
String DB_URL =     "jdbc:oracle:thin:@....";                // 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 ( DB_URL, DB_USER, DB_PASSWD, DB );
ModelMaker maker = ModelFactory.createModelRDBMaker(conn) ;

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

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

Notes