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

Logging Connection

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

In addition to logging things on a jOOQ level, there is also the option of logging things on the JDBC level using the org.jooq.tools.jdbc.LoggingConnection. This connection acts as a JDBC proxy, intercepting all relevant calls in order to DEBUG log relevant information to slfj4 or java.util.logging.

try (Connection logging = new LoggingConnection(datasource.getConnection())) {
    
    // Run statements directly with JDBC
    try (Statement s = c.createStatement()) {
        s.executeUpdate("INSERT INTO author (id, first_name, last_name) VALUES (3, 'William', 'Shakespeare')";
    }
    
    // ... or wrap the connection with jOOQ
    DSL.using(logging, dialect)
       .insertInto(AUTHOR)
       .columns(AUTHOR.ID, AUTHOR.FIRST_NAME, AUTHOR.LAST_NAME)
       .values(3, "William", "Shakespeare")
       .execute();
}

Feedback

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

The jOOQ Logo