Configuration

To use an H2 database you must set the Bootstrap.properties1file to specify the set of properties relevant to H2 for obtaining a connection to the database; e.g.:

Figure 1. Bootstrap.properties
curam.db.type=h2
curam.db.name=curamdb
curam.db.username=curam
curam.db.password=qqnscP4c4+s=
# H2 directory.
# Default is home directory
# (i.e. C:/Documents and Settings/<username>). (Optional)
curam.db.h2.directory=C:/H2
# Mode remote|embedded
curam.db.h2.mode=embedded
# For remote mode also specify:
curam.db.serverport=9092
curam.db.servername=localhost
# Lock Time Out in ms. Default is 1000, i.e. 1 second. (Optional)
curam.db.h2.locktimeout=20000
# Property to disable MVCC. Default: true. (Optional)
curam.db.h2.mvcc=true

Once you have updated Bootstrap.properties and rebuilt the server and database you can develop in exactly the same way as you would with Oracle or DB2.

H2 Modes

The following H2 modes are supported for application development:

You can specify the required mode by using the following property in Bootstrap.properties file:

# Mode remote|embedded
curam.db.h2.mode=embedded

Multi-Version Concurrency Control (MVCC)

The MVCC feature allows higher concurrency than using exclusive table level or row level locks. When using MVCC in this database, delete, insert and update operations will only issue a shared lock on the table. An exclusive lock is still used when adding or removing columns, when dropping the table, and when using SELECT... FOR UPDATE. Connections only 'see' committed data, and their own changes. That means, if connection A updates a row but hasn't committed the change, connection B will see the old value. Only when the change from connection A is committed, the new value is visible to other connections (read committed). If multiple connections concurrently try to update the same row, the database waits until it can apply the change, but at most until the lock timeout expires.

By default, MVCC is set to true.

You can switch off MVCC by using the following property in Bootstrap.properties file:

# Property to disable MVCC. Default: true. (Optional)
curam.db.h2.mvcc=false

H2 Web Console

When you start H2 by running the org.h2.tools.Server class in h2.jar its web console is started and can be accessed at the URL:

http://localhost:8082/

The JDBC connection URL you specify in the login screen is based on the curam.db.name, curam.db.username, and curam.db.h2.directory values in Bootstrap.properties, which define the database name, SCHEMA name, and the database location in the file system. So, if your database name is curamdb, your username is curam and curam.db.h2.directory is defaulting to your home directory, your JDBC string would look like this:

jdbc:h2:tcp://localhost/~/curamdb;schema=curam;FILE_LOCK=SOCKET

Note, if, for example, curam.db.h2.directory is C:/H2, then your JDBC string would look like this:

jdbc:h2:tcp://localhost/file:C:/H2/curamdb;schema=curam;FILE_LOCK=SOCKET

Specify the values for User Name and Password as in your Bootstrap.properties and then click the Connect (or Test Connect) button. Once connected you'll have an SQL text control, etc. available.

1 For more information on Bootstrap.properties consult the Cúram Server Developers Guide.