Provides an implementation for the {@link org.netbeans.mdr.persistence abstract MDR persistence interfaces } in terms of {@link java.sql JDBC }.

JDBC Persistence for MDR

The JdbcStorage implementation relies on a JDBC driver and associated SQL DBMS for transactional persistence. The DBMS can be a lightweight Java database running in the same process as MDR, a heavyweight database running out-of-process on the same machine, or even across the network (although performance may be poor in this configuration).

Parameters

In order to use JdbcStorage, some mandatory properties must be specified: There are also some optional connection parameters:

The next section defines additional parameters affecting DBMS-specific usage of SQL.

Index to Table Mapping

JdbcStorage creates one table per MDR index. It also creates one private table (MOFID_SEQ) for implementing the MOFID sequence generator. No metadata tables are created; instead, JdbcStorage relies on DBMS metadata. This avoids redundancy and the possibility for inconsistency, and makes it easier to see the relationship between MDR objects and their SQL implementations. Datatypes for index key and value columns can be controlled via the properties listed below. The defaults may not be supported by every DBMS. For example, PostgreSQL requires usage of type BYTEA in place of LONGVARBINARY. Also, users may wish to override the default precision depending on the application. Additional columns may be created as follows (using the datatype specified by the datatype.int property above): The primary key is defined as the key column, plus the ordinal and surrogate key columns (if any).

Table Names

If the DBMS does not support schemas, JdbcStorage fakes them by prepending the specified schema name to the name of each table created (e.g. MDR_MOFID_SEQ). In this case, a distinguishing value should be used for the schema name, since JdbcStorage.delete() will delete all tables whose names have this prefix.

Table names are derived from the index names requested by MDR. However, the index name is not used directly, because MDR generates very long index names based on MOFID's, and many DBMS products have a low limit like 31 characters for identifiers. To shorten the name, the StorageId portion of each MOFID is eliminated, and all leading zeros of the serial number are trimmed.

Caching

{@link org.netbeans.mdr.persistence.jdbcimpl.JdbcPrimaryIndex} reuses the streamable object caching strategy from {@link org.netbeans.mdr.persistence.btreeimpl.btreestorage.MDRCache }. For other indexes, no caching is currently performed.

Driver and DBMS Requirements

JdbcStorage has been tested with hsqldb 1.7.1 and PostgreSQL 7.4.1. It does not require a sophisticated JDBC driver or DBMS, but may require some tweaks for other products. Below is a list of the JDBC and SQL features it uses:

Limitations and Unresolved Issues

Since this is a first cut, there is lots of room for improvement: In addition, there are various unresolved issues which came up during development: