Dropwizard jOOQ Bundle

Build Status Coverage Status

An addon bundle in the vein of dropwizard-hibernate for using the excellent jOOQ SQL library in Dropwizard applications.

Dependency Info



Add a JooqBundle to your Application class.

public void initialize(Bootstrap<MyConfiguration> bootstrap) {
    // ...
    bootstrap.addBundle(new JooqBundle<AppConfig>() {
        public DataSourceFactory getDataSourceFactory(AppConfig configuration) {
            return configuration.getDataSourceFactory();

        public JooqFactory getJooqFactory(AppConfig configuration) {
            return configuration.getJooqFactory();

This will enable @Context injection of jOOQ Configuration and DSLContext parameters in resource methods:

public BlogPost getPost(@QueryParam("id") int postId, @Context DSLContext database) {
    BlogPostRecord post = database

    // do stuff

This will also enable database healthchecks and install exception mappers.

Finally, because I <3 postgres and jOOQ can lag behind some of its features, PostgresSupport provides a few helpers for aggregating array values in queries.

For example (taken from the sample project):

import static com.bendb.dropwizard.jooq.PostgresSupport.arrayAgg;


Code Generation

dropwizard-jooq provides some classes for making generated pojos, DAOs, etc. more convenient to use.

JodaDateTimeConverter can be used to map between java.sql.Timestamp and Joda DateTime objects. This is currently the only converter bundled; contributions in this area are welcome!


dropwizard-jooq uses the same DataSourceFactory for configuring its DataSource.

For modifying jOOQ configuration settings, there is JooqFactory:

  # The flavor of SQL to generate. If not specified, it will be inferred from the JDBC connection URL.  (default: null)
  dialect: POSTGRES
  # DEPRECATED: Use `executeLogging` instead (default: no)
  logExecutedSql: yes
  # Whether to include schema names in generated SQL.  (default: yes)
  renderSchema: yes
  # How names should be rendered in generated SQL.  One of QUOTED, AS_IS, LOWER, or UPPER.  (default: QUOTED)
  renderNameStyle: QUOTED
  # How keywords should be rendered in generated SQL.  One of LOWER, UPPER.  (default: UPPER)
  renderKeywordStyle: LOWER
  # Whether generated SQL should be pretty-printed.  (default: no)
  renderFormatted: no
  # How parameters should be represented.  One of INDEXED, NAMED, or INLINE.  (default: INDEXED)
  paramType: INDEXED
  # How statements should be generated; one of PREPARED_STATEMENT or STATIC_STATEMENT.  (default: PREPARED_STATEMENT)
  # Whether internal jOOQ logging should be enabled.  (default: no)
  executeLogging: no
  # Whether optimistic locking should be enabled.  (default: no)
  executeWithOptimisticLocking: no
  # Whether returned records should be 'attached' to the jOOQ context.  (default: yes)
  attachRecords: yes
  # Whether primary-key fields should be updatable.  (default: no)
  updatablePrimaryKeys: no


Please file bug reports and feature requests in GitHub issues.


Copyright © 2014-2020 Benjamin Bader

This library is licensed under the Apache License, Version 2.0.

See http://www.apache.org/licenses/LICENSE-2.0.html or the LICENSE file in this repository for the full license text.