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

Connection access

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

Occasionally, you may want to access a JDBC java.sql.Connection from jOOQ. This can be done easily using DSLContext.connection() or DSLContext.connectionResult()

// When you don't produce any results:
create.connection(c -> {
    try (Statement s = c.createStatement()) {
        s.executeUpdate("INSERT INTO author (id, first_name, last_name) VALUES (3, 'William', 'Shakespeare')";
    }
});

// When you produce results
int rows = create.connection(c -> {
    try (Statement s = c.createStatement()) {
        return s.executeUpdate("INSERT INTO author (id, first_name, last_name) VALUES (3, 'William', 'Shakespeare')";
    }
});

Feedback

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

The jOOQ Logo