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

This documentation is for the unreleased development version of jOOQ. Click on the above version links to get this documentation for a supported version of jOOQ.

The DSLContext API

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

DSLContext references a org.jooq.Configuration, an object that configures jOOQ's behaviour when executing queries (see SQL execution for more details). Unlike the static DSL, the DSLContext allow for creating SQL statements that are already "configured" and ready for execution.

Fluent creation of a DSLContext object

The DSLContext object can be created fluently from the DSL type:

// Create it from a pre-existing configuration
DSLContext create = DSL.using(configuration);

// Create it from ad-hoc arguments
DSLContext create = DSL.using(connection, dialect);

If you do not have a reference to a pre-existing Configuration object (e.g. created from org.jooq.impl.DefaultConfiguration), the various overloaded DSL.using() methods will create one for you.

Contents of a Configuration object

A Configuration can be supplied with these objects:

Usage of DSLContext

Wrapping a Configuration object, a DSLContext can construct statements, for later execution. An example is given here:

// The DSLContext is "configured" with a Connection and a SQLDialect
DSLContext create = DSL.using(connection, dialect);

// This select statement contains an internal reference to the DSLContext's Configuration:
Select<?> select = create.selectOne();

// Using the internally referenced Configuration, the select statement can now be executed:
Result<?> result = select.fetch();

Note that you do not need to keep a reference to a DSLContext. You may as well inline your local variable, and fluently execute a SQL statement as such:

// Execute a statement from a single execution chain:
Result<?> result =
DSL.using(connection, dialect)

Table of contents

SQL Dialect
SQL Dialect Family
SQL Dialect Category
Connection vs. DataSource
Custom data
Custom ExecuteListeners
Custom Unwrappers
Custom Settings
Auto-attach Records
Auto-inline bind values
Backslash Escaping
Batch size
Computed column emulation
Diagnostics Connection
Diagnostics Logging
Dialect compatibility
Dollar quoted string token
Execute Logging
Execute Logging SQL Exceptions
Fetching trimmed CHAR types (new)
Fetch Warnings
GROUP_CONCAT Configuration
Identifier style
Implicit join type
Inline Threshold
IN-list Padding
Interpreter Configuration
JDBC Flags
Keyword style
Listener Invocation Order
Map JPA Annotations
Object qualification
Object qualification for columns
Optimistic Locking
Parameter name prefix
Parameter types
Parser Configuration
Reflection caching
Return all columns on store
Return computed columns on store
Return DEFAULT columns on store
Return Identity Value On Store
Runtime catalog, schema and table mapping
Scalar subqueries for stored functions
SEEK clause implementation
Statement Type
Updatable Primary Keys
Thread safety

previous : next


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

The jOOQ Logo