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

SQL execution

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

In a previous section of the manual, we've seen how jOOQ can be used to build SQL that can be executed with any API including JDBC or ... jOOQ. This section of the manual deals with various means of actually executing SQL with jOOQ.

SQL execution with JDBC

JDBC calls executable objects "java.sql.Statement". It distinguishes between three types of statements:

Today, the JDBC API may look weird to users being used to object-oriented design. While statements hide a lot of SQL dialect-specific implementation details quite well, they assume a lot of knowledge about the internal state of a statement. For instance, you can use the PreparedStatement.addBatch() method, to add a the prepared statement being created to an "internal list" of batch statements. Instead of returning a new type, this method forces user to reflect on the prepared statement's internal state or "mode".

jOOQ is wrapping JDBC

These things are abstracted away by jOOQ, which exposes such concepts in a more object-oriented way. For more details about jOOQ's batch query execution, see the manual's section about batch execution.

The following sections of this manual will show how jOOQ is wrapping JDBC for SQL execution

Alternative execution modes

Just because you can, doesn't mean you must. At the end of this chapter, we'll show how you can use jOOQ to generate SQL statements that are then executed with other APIs, such as Spring's JdbcTemplate, or Hibernate. For more information see the section about alternative execution models.

Table of contents

5.1.
Comparison between jOOQ and JDBC
5.2.
Query vs. ResultQuery
5.3.
Fetching
5.3.1.
Record vs. TableRecord
5.3.2.
Record1 to Record22
5.3.3.
Arrays, Maps and Lists
5.3.4.
RecordHandler
5.3.5.
RecordMapper
5.3.6.
POJOs
5.3.7.
The RecordMapperProvider SPI
5.3.8.
Ad-hoc Converter
5.3.9.
ConverterProvider
5.3.10.
Lazy fetching
5.3.11.
Lazy fetching with Streams
5.3.12.
Many fetching
5.3.13.
Later fetching
5.3.14.
Reactive Fetching
5.3.15.
ResultSet fetching
5.3.16.
Auto data type conversion
5.3.17.
Custom data type conversion
5.3.18.
Context Converter
5.4.
Static statements vs. Prepared Statements
5.5.
Reusing a Query's PreparedStatement
5.6.
JDBC flags
5.7.
Using JDBC batch operations
5.8.
Sequence execution
5.9.
Stored procedures and functions
5.9.1.
Oracle Packages
5.9.2.
Oracle member procedures
5.10.
Exporting to XML, CSV, JSON, HTML, Text, Charts
5.10.1.
Exporting XML
5.10.2.
Exporting CSV
5.10.3.
Exporting JSON
5.10.4.
Exporting HTML
5.10.5.
Exporting Text
5.10.6.
Exporting Charts
5.10.7.
FormattingProvider
5.11.
Importing data
5.11.1.
The Loader API
5.11.2.
Import options
5.11.2.1.
Throttling
5.11.2.2.
Duplicate handling
5.11.2.3.
Error handling
5.11.3.
Import data sources
5.11.3.1.
Importing CSV
5.11.3.2.
Importing JSON
5.11.3.3.
Importing records
5.11.3.4.
Importing arrays
5.11.3.5.
Importing XML
5.11.4.
Import listeners
5.11.5.
Import result and error handling
5.12.
CRUD with UpdatableRecords
5.12.1.
Simple CRUD
5.12.2.
Records' internal flags
5.12.3.
IDENTITY values
5.12.4.
Navigation methods
5.12.5.
Non-updatable records
5.12.6.
Optimistic locking
5.12.7.
Batch execution
5.12.8.
CRUD SPI: RecordListener
5.13.
DAOs
5.14.
Transaction management
5.15.
Exception handling
5.16.
ExecuteListeners
5.17.
Database meta data
5.17.1.
JDBC meta data
5.17.2.
Interpreted meta data
5.17.3.
XML meta data
5.17.4.
Generated meta data
5.18.
JDBC Connection
5.19.
Batched Connection
5.20.
Mocking Connection
5.21.
Mock File Database
5.22.
Parsing Connection
5.23.
Diagnostics
5.23.1.
Too Many Rows
5.23.2.
Too Many Columns
5.23.3.
Duplicate Statements
5.23.4.
Repeated statements
5.23.5.
Consecutive aggregation
5.23.6.
WasNull calls
5.23.7.
Concatenation in predicates
5.23.8.
Possibly wrong expressions
5.23.9.
Trivial condition
5.23.10.
Transform patterns
5.24.
Logging with LoggerListener
5.25.
Logging with SQLExceptionLoggerListener
5.26.
Logging Connection
5.27.
Logging system properties (new)
5.28.
Performance considerations
5.29.
Alternative execution models
5.29.1.
Using jOOQ with Spring's JdbcTemplate
5.29.2.
Using jOOQ with JPA
5.29.2.1.
Using jOOQ with JPA Native Query
5.29.2.2.
Using jOOQ with JPA entities
5.29.2.3.
Using jOOQ with JPA EntityResult

previous : next

Feedback

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

The jOOQ Logo