HowTo Use PostgreSQL Database System with Jena2

What is PostgreSQL

PostgreSQL (pronounced Post-Gres-Q-L.) is an enhancement of the POSTGRES database management system, a DBMS research prototype developed at the University of California-Berkeley in the 1990s. PostgreSQL is open source and supported by an active developer community.  It runs on a variety of hardware and software platforms with excellent performance. See http://www.postgresql.org for more information.

Download and Installation of PostgreSQL

The PostgreSQL binary distribution can be used with Jena.  As of PostgreSQL version 8, there are native binaries for Linux and MS Windows. PostgreSQL version 7 requires Cygwin to run on MS Windows and is more complicated to install.

If you prefer the source code distribution, see the instructions at http://www.postgresql.org for downloading and building from the source.

Connecting Your Jena Program to PostgreSQL

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.

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.

Notes

Jena stores all models in a single database using whatever database (name) is specified on the database connection. See the Jena Database Release Notes for details on the physical layout.