New versions: Dev (3.15) | Latest (3.14) | 3.13 | 3.12 | 3.11 | 3.10 | 3.9

Database name and properties

Applies to ✅ Open Source Edition   ✅ Express Edition   ✅ Professional Edition   ✅ Enterprise Edition

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 (standalone and maven)
Programmatic
Gradle
<configuration xmlns="http://www.jooq.org/xsd/jooq-codegen-3.10.0.xsd">
  <generator>
    <database>
      <name>org.jooq.meta.xml.XMLDatabase</name>
      <properties>
        <property>
          <key>dialect</key>
          <value>MYSQL</value>
        </property>
        <property>
          <key>xmlFile</key>
          <value>/path/to/database.xml</value>
        </property>
      </properties>
    </database>
  </generator>
</configuration>
new org.jooq.meta.jaxb.Configuration()
  .withGenerator(new Generator()
    .withDatabase(new Database()
      .withName("org.jooq.meta.xml.XMLDatabase")
      .withProperties(
        new Property()
          .withKey("dialect")
          .withValue("MYSQL"),
        new Property()
          .withKey("xmlFile")
          .withValue("/path/to/database.xml")
      )
    )
  )
myConfigurationName(sourceSets.main) {
  generator {
    database {
      name = 'org.jooq.meta.xml.XMLDatabase'
      properties {
        property {
          key = 'dialect'
          value = 'MYSQL'
        }
        property {
          key = 'xmlFile'
          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.util.ase.ASEDatabase
  • org.jooq.util.cubrid.CUBRIDDatabase
  • org.jooq.util.db2.DB2Database
  • org.jooq.util.derby.DerbyDatabase
  • org.jooq.util.firebird.FirebirdDatabase
  • org.jooq.util.h2.H2Database
  • org.jooq.util.hana.HanaDatabase
  • org.jooq.util.hsqldb.HSQLDBDatabase
  • org.jooq.util.informix.InformixDatabase
  • org.jooq.util.ingres.IngresDatabase
  • org.jooq.util.mariadb.MariaDBDatabase
  • org.jooq.util.mysql.MySQLDatabase
  • org.jooq.util.oracle.OracleDatabase
  • org.jooq.util.postgres.PostgresDatabase
  • org.jooq.util.redshift.RedshiftDatabase
  • org.jooq.util.sqlite.SQLiteDatabase
  • org.jooq.util.sqlserver.SQLServerDatabase
  • org.jooq.util.sybase.SybaseDatabase
  • org.jooq.util.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.util.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.util.Database from the jooq-meta module.

Note: The classes have been moved to org.jooq.meta in jOOQ 3.11

Feedback

Do you have any feedback about this page? We'd love to hear it!

The jOOQ Logo