Database Support

Using H2, MySQL, PostgreSQL, Oracle, or DB2 with JBatch

You can configure JBatch any of the following RDBMS engines in the same way that you would configure it to use Derby:

  • H2

  • MySQL

  • PostgreSQL

  • Oracle

  • IBM DB2

Configuration

On the administration console:

  1. Create a Connection Pool:

    1. Navigate to ResourcesJDBCJDBC Connection Pools and click on New…​

    2. Give it a name in the Pool Name field, select the resource type from the Resource Type drop-down, and choose the Database Driver Vendor as either H2, DB2, MySQL, Oracle, or PostgreSQL from the Database Driver Vendor menu.

    3. Set any further configuration options on the next page.

    4. Click Finish

  2. Create a JDBC Resource:

    1. Navigate to ResourcesJDBCJDBC Resources and click on New…​

    2. Give it a name in the JNDI Name field, and select the data source you just created from the Pool Name drop-down.

    3. Add any additional properties and select the targets for it to be enabled on.

    4. Click OK.

  3. Navigate to the Batch configuration page of the instance or cluster:

  4. Click on the instance or cluster to move to its configuration page.

  5. Select the Batch tab, and the Configuration sub-tab should load.

  6. Select the new data source from the Data Source Lookup Name drop-down menu.

  7. Save the changes.

Usage Restrictions

JBatch will not create internally more than one set of JBatch tables per schema. So in your schema if there exists a set of JBatch tables with prefixes and suffixes in the table names and then specify in the Glassfish JBatch configuration for the same schema above that you wish to use JBatch tables under a different name (for example no table prefix and suffix) then during the JBatch initialization phase, JBatch will attempt to create these tables since they do not exist.

However since the table constraint names already exist for the existing JBatch tables in the same schema, table creation will fail. One can of course run a SQL script to create the relevant JBatch schema objects under different names.

MySQL Specifics

For MySQL database use, it is recommended the following additional property be set:

Name Value Description

zeroDateTimeBehavior

convertToNull

Action for DATETIME values that are composed entirely of zeros (used by MySQL to represent invalid dates)

Depending on the version of MySQL you may also need to set the server property sql_mode to blank as JBatch uses null and zero dates.