IBM Db2

Use IBM Db2 as the JobRunr StorageProvider - driver dependency, configuration, and table creation.

On this page

JobRunr stores all background jobs in IBM Db2 through the DB2StorageProvider. JobRunr is tested against Db2 container version 12.1.0.0.

Add the driver dependency

Add the IBM Db2 JDBC driver (JCC) to your project. The latest version is on Maven Central.

<dependency>
  <groupId>com.ibm.db2</groupId>
  <artifactId>jcc</artifactId>
  <version><!-- latest version --></version>
</dependency>

Configuration

If you use a framework starter, JobRunr automatically detects your existing DataSource - configure your database the usual way and you are done.

HikariConfig config = new HikariConfig();
config.setJdbcUrl("jdbc:db2://localhost:50000/mydb");
config.setUsername("myuser");
config.setPassword("mypassword");
DataSource dataSource = new HikariDataSource(config);

JobRunr.configure()
    .useStorageProvider(SqlStorageProviderFactory.using(dataSource))
    .useBackgroundJobServer()
    .initialize();

Creating the tables

By default JobRunr creates its tables automatically. If you want to create them yourself, use the DatabaseCreator or generate the SQL scripts with migration type db2. See Setting up an SQL database.

Next steps

Looking for another database? Back to the Storage overview.