Available in versions: Dev (3.20) | Latest (3.19) | 3.18 | 3.17 | 3.16 | 3.15 | 3.14 | 3.13 | 3.12 | 3.11 | 3.10

Programmatic generator configuration

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

Configuring your code generator with Java, Groovy, etc.

In the previous sections, we have covered how to set up jOOQ's code generator using XML, either by running a standalone Java application, or by using Maven. However, it is also possible to use jOOQ's GenerationTool programmatically. The XSD file used for the configuration (https://www.jooq.org/xsd/jooq-codegen-3.17.0.xsd) is processed using XJC to produce Java artefacts. The below example uses those artefacts to produce the equivalent configuration of the previous PostgreSQL / Maven example:

// Use the fluent-style API to construct the code generator configuration
import org.jooq.meta.jaxb.*;
import org.jooq.meta.jaxb.Configuration;

// [...]

Configuration configuration = new Configuration()
    .withJdbc(new Jdbc()
    .withGenerator(new Generator()
        .withDatabase(new Database()
        .withTarget(new Target()


For the above example, you will need all of jooq-3.17.26.jar, jooq-meta-3.17.26.jar, and jooq-codegen-3.17.26.jar, on your classpath.

Manually loading the XML file

Alternatively, you can also load parts of the configuration from an XML file using JAXB and programmatically modify other parts using the code generation API:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
        <!-- ... -->

Load the above using standard JAXB API:

import java.io.File;
import jakarta.xml.bind.JAXB;
import org.jooq.meta.jaxb.Configuration;

// [...]
// and then

Configuration configuration = JAXB.unmarshal(new File("jooq.xml"), Configuration.class);


... and then, modify parts of your configuration programmatically, for instance the JDBC user / password:


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

The jOOQ Logo