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:
-
Create a Connection Pool:
-
Navigate to Resources → JDBC → JDBC Connection Pools and click on New…
-
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.
-
Set any further configuration options on the next page.
-
Click Finish
-
-
Create a JDBC Resource:
-
Navigate to Resources → JDBC → JDBC Resources and click on New…
-
Give it a name in the JNDI Name field, and select the data source you just created from the Pool Name drop-down.
-
Add any additional properties and select the targets for it to be enabled on.
-
Click OK.
-
-
Navigate to the Batch configuration page of the instance or cluster:
-
Click on the instance or cluster to move to its configuration page.
-
Select the Batch tab, and the Configuration sub-tab should load.
-
Select the new data source from the Data Source Lookup Name drop-down menu.
-
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.
|