JobRunr Pro

CockroachDB

Use CockroachDB as the JobRunr StorageProvider - driver dependency, configuration, and version requirements.

On this page

JobRunr stores all background jobs in CockroachDB through the CockroachStorageProvider.

Important

JobRunr requires CockroachDB v25.1 or later. Versions 24.x and lower fail due to migration script incompatibilities.

Add the driver dependency

CockroachDB is wire-compatible with PostgreSQL, so it uses the PostgreSQL JDBC driver. The latest version is on Maven Central.

<dependency>
  <groupId>org.postgresql</groupId>
  <artifactId>postgresql</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. CockroachDB uses the PostgreSQL driver (jdbc:postgresql://...).

HikariConfig config = new HikariConfig();
config.setJdbcUrl("jdbc:postgresql://localhost:26257/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 cockroach. See Setting up an SQL database.

Next steps

Looking for another database? Back to the Storage overview.