OpenJMS requires a JDBC 2.0 compliant database.
As of release 0.7.7, OpenJMS is distributed pre-configured with Derby, a pure Java database. This is provided to demonstrate OpenJMS' features "out-of-the-box", and may change in future.
To configure OpenJMS to use a JDBC database:
Edit the %OPENJMS_HOME%\bin\setenv.bat batch file:
rem Configures the JDBC driver set CLASSPATH=<insert path to JDBC driver here>
Edit the $OPENJMS_HOME/bin/setenv.sh script:
# Configures the JDBC driver CLASSPATH=<insert path to JDBC driver here>
The JDBC driver connection properties need to be added to the OpenJMS configuration file, $OPENJMS_HOME/config/openjms.xml, e.g:
<DatabaseConfiguration> <RdbmsDatabaseConfiguration driver="oracle.jdbc.driver.OracleDriver" url="jdbc:oracle:oci8:@myhost" user="openjms" password="openjms" /> </DatabaseConfiguration>
The dbtool application may be used to create, drop, and recreate the OpenJMS database tables.
To create the tables on open up a command prompt and type:
cd %OPENJMS_HOME%\bin dbtool.bat -create -config %OPENJMS_HOME%\config\openjms.xml
cd $OPENJMS_HOME/bin dbtool.sh -create -config $OPENJMS_HOME/config/openjms.xml
The dbtool application may not support all available JDBC drivers, due to buggy JDBC implementations. In this case, the tables must be manually created. The OpenJMS distribution ships with SQL scripts for most popular databases. These scripts are located in the $OPENJMS_HOME/db/sql directory and are named in the form of create_db.sql (e.g create_oracle.sql, create_mysql.sql)
For example, to manually create the tables in an Oracle database:
sqlplus user/password @create_oracle.sql
OpenJMS uses a pool of JDBC connections, for performance reasons. This can be configured via the <RdbmsDatabaseConfiguration> element. E.g.:
<RdbmsDatabaseConfiguration driver="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost/openjms" user="openjms" password="openjms" maxActive="10" maxIdle="5" evictionInterval="3600" testQuery="select current_date"/>
The above specifies to use MySQL as the JDBC provider, with the connection pool configured as follows: