New versions: Dev (3.15) | Latest (3.14) | 3.13 | 3.12 | 3.11 | 3.10 | 3.9 | 3.8 | Old versions: 3.7 | 3.6 | 3.5 | 3.4 | 3.3 | 2.6
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:
- java.sql.Statement, or "static statement": This statement type is used for any arbitrary type of SQL statement. It is particularly useful with inlined parameters
- java.sql.PreparedStatement: This statement type is used for any arbitrary type of SQL statement. It is particularly useful with indexed parameters (note that JDBC does not support named parameters)
- java.sql.CallableStatement: This statement type is used for SQL statements that are "called" rather than "executed". In particular, this includes calls to stored procedures. Callable statements can register OUT parameters
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
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.
- Arrays, Maps and Lists
- 5.3.3.
- RecordHandler
- 5.3.4.
- RecordMapper
- 5.3.5.
- POJOs
- 5.3.6.
- Lazy fetching
- 5.3.7.
- Many fetching
- 5.3.8.
- Later fetching
- 5.3.9.
- ResultSet fetching
- 5.3.10.
- Data type conversion
- 5.4.
- Static statements vs. Prepared Statements
- 5.5.
- Reusing a Query's PreparedStatement
- 5.6.
- Using JDBC batch operations
- 5.7.
- Sequence execution
- 5.8.
- Stored procedures and functions
- 5.8.1.
- Oracle Packages
- 5.8.2.
- Oracle member procedures
- 5.9.
- Exporting to XML, CSV, JSON, HTML, Text
- 5.9.1.
- Exporting XML
- 5.9.2.
- Exporting CSV
- 5.9.3.
- Exporting JSON
- 5.9.4.
- Exporting HTML
- 5.9.5.
- Exporting Text
- 5.10.
- Importing data
- 5.10.1.
- Importing CSV
- 5.10.2.
- Importing XML
- 5.11.
- CRUD with UpdatableRecords
- 5.11.1.
- Simple CRUD
- 5.11.2.
- IDENTITY values
- 5.11.3.
- Navigation methods
- 5.11.4.
- Non-updatable records
- 5.11.5.
- Optimistic locking
- 5.11.6.
- Batch execution
- 5.12.
- DAOs
- 5.13.
- Exception handling
- 5.14.
- ExecuteListeners
- 5.15.
- Logging
- 5.16.
- Performance considerations
The jOOQ User Manual : SQL execution | previous : next |
Feedback
Do you have any feedback about this page? We'd love to hear it!