All versions: 3.11 | 3.10 | 3.9 | Development versions: 3.12

The two main elements in the <database/> element are <name/> and <properties>, which specify the class to implement the database meta data source, and an optional list of key/value parameters:

XML configuration (standalone and Maven)

<configuration xmlns="http://www.jooq.org/xsd/jooq-codegen-3.11.0.xsd">
  <generator>
    <database>
      <name>org.jooq.meta.xml.XMLDatabase</name>
      <properties>
        <property>
          <key>dialect</key>
          <value>MYSQL</value>
        </property>
        <property>
          <key>xml-file</key>
          <value>/path/to/database.xml</value>
        </property>
      </properties>
    </database>
  </generator>
</configuration>

Programmatic configuration

configuration
  .withGenerator(new Generator(
    .withDatabase(new Database()
      .withName("org.jooq.meta.xml.XMLDatabase")
      .withProperties(
        new Property().withKey("dialect").withValue("MYSQL"),
        new Property().withKey("xml-file").withValue("/path/to/database.xml")))));

Gradle configuration

myConfigurationName(sourceSets.main) {
  generator {
    database {
      name = 'org.jooq.meta.xml.XMLDatabase'
      properties {
        property {
          key = 'dialect'
          value = 'MYSQL'
        }
        property {
          key = 'xml-file'
          value = '/path/to/database.xml'
        }
      }
    }
  }
}

The default <name/> if no name is supplied will be derived from the JDBC connection. If you want to specifically specify your SQL dialect's database name, any of these values will be supported by jOOQ, out of the box:

  • org.jooq.meta.ase.ASEDatabase
  • org.jooq.meta.cubrid.CUBRIDDatabase
  • org.jooq.meta.db2.DB2Database
  • org.jooq.meta.derby.DerbyDatabase
  • org.jooq.meta.firebird.FirebirdDatabase
  • org.jooq.meta.h2.H2Database
  • org.jooq.meta.hana.HanaDatabse
  • org.jooq.meta.hsqldb.HSQLDBDatabase
  • org.jooq.meta.informix.InformixDatabase
  • org.jooq.meta.ingres.IngresDatabase
  • org.jooq.meta.mariadb.MariaDBDatabase
  • org.jooq.meta.mysql.MySQLDatabase
  • org.jooq.meta.oracle.OracleDatabase
  • org.jooq.meta.postgres.PostgresDatabase
  • org.jooq.meta.redshift.RedshiftDatabase
  • org.jooq.meta.sqlite.SQLiteDatabase
  • org.jooq.meta.sqlserver.SQLServerDatabase
  • org.jooq.meta.sybase.SybaseDatabase
  • org.jooq.meta.vertica.VerticaDatabase

Alternatively, you can also specify the following database if you want to reverse-engineer a generic JDBC java.sql.DatabaseMetaData source for an unsupported database version / dialect / etc:

  • org.jooq.meta.jdbc.JDBCDatabase

Furthermore, there are two out-of-the-box database meta data sources, that do not rely on a JDBC connection: the JPADatabase (to reverse engineer JPA annotated entities) and the XMLDatabase (to reverse engineer an XML file). Please refer to the respective sections for more details.

Last, but not least, you can of course implement your own by implementing org.jooq.meta.Database from the jooq-meta module.

The jOOQ Logo