Package org.jooq

Interface DSLContext

  • All Superinterfaces:
    java.lang.AutoCloseable, Scope
    All Known Implementing Classes:
    DefaultDSLContext

    public interface DSLContext
    extends Scope, java.lang.AutoCloseable
    A contextual DSL providing "attached" implementations to the org.jooq interfaces.

    Apart from the DSL, this contextual DSL is the main entry point for client code, to access jOOQ classes and functionality that are related to Query execution. Unlike objects created through the DSL type, objects created from a DSLContext will be "attached" to the DSLContext's Scope.configuration(), such that they can be executed immediately in a fluent style. An example is given here:

     DSLContext create = DSL.using(connection, dialect);
    
     // Immediately fetch results after constructing a query
     create.selectFrom(MY_TABLE).where(MY_TABLE.ID.eq(1)).fetch();
    
     // The above is equivalent to this "non-fluent" style
     create.fetch(DSL.selectFrom(MY_TABLE).where(MY_TABLE.ID.eq(1)));
     

    The DSL provides convenient constructors to create a Configuration, which will be shared among all Query objects thus created. Optionally, you can pass a reusable Configuration to the DSL.using(Configuration) constructor. Please consider thread-safety concerns documented in Configuration, should you want to reuse the same Configuration instance in various threads and / or transactions.

    Author:
    Lukas Eder
    See Also:
    DSL, Configuration
    • Method Detail

      • map

        Schema map​(Schema schema)
        Map a schema to another one.

        This will map a schema onto another one, depending on configured schema mapping in this DSLContext. If no applicable schema mapping can be found, the schema itself is returned.

        Parameters:
        schema - A schema
        Returns:
        The mapped schema
      • map

        <R extends RecordTable<R> map​(Table<R> table)
        Map a table to another one.

        This will map a table onto another one, depending on configured table mapping in this DSLContext. If no applicable table mapping can be found, the table itself is returned.

        Parameters:
        table - A table
        Returns:
        The mapped table
      • parser

        Parser parser()
        Access the parser API.

        This is experimental functionality.

      • parsingConnection

        java.sql.Connection parsingConnection()
        A JDBC connection that runs each statement through the parser() first, prior to re-generating and running the SQL.

        The resulting Connection wraps an underlying JDBC connection that has been obtained from ConnectionProvider.acquire() and must be released by calling Connection.close().

        This is experimental functionality:

      • parsingDataSource

        javax.sql.DataSource parsingDataSource()
        A JDBC data source that runs each statement through the parser() first, prior to re-generating and running the SQL.

        This simply wraps the parsingConnection() in a DataSource.

      • diagnosticsConnection

        java.sql.Connection diagnosticsConnection()
        A JDBC connection that proxies the underlying connection to run the jOOQ Diagnostics Pack on executed queries.

        This is experimental functionality.

      • diagnosticsDataSource

        javax.sql.DataSource diagnosticsDataSource()
        A JDBC connection that proxies the underlying connection to run the jOOQ Diagnostics Pack on executed queries.

        This simply wraps the diagnosticsConnection() in a DataSource.

      • meta

        Meta meta​(java.sql.DatabaseMetaData meta)
        Access the database meta data from an explicit JDBC DatabaseMetaData.
      • meta

        Meta meta​(Catalog... catalogs)
        Access the database meta data from explicit catalog information.

        This will not connect to your database to get live meta information, unlike meta() and meta(DatabaseMetaData).

      • meta

        Meta meta​(Schema... schemas)
        Access the database meta data from explicit schema information.

        This will not connect to your database to get live meta information, unlike meta() and meta(DatabaseMetaData).

      • meta

        Meta meta​(Table<?>... tables)
        Access the database meta data from explicit table information.

        This will not connect to your database to get live meta information, unlike meta() and meta(DatabaseMetaData).

      • informationSchema

        InformationSchema informationSchema​(Table<?> table)
        Export a table to the InformationSchema format.

        Exporting a single table will not include any foreign key definitions in the exported data.

        This allows for serialising schema meta information as XML using JAXB. See also Constants.XSD_META for details.

      • informationSchema

        InformationSchema informationSchema​(Table<?>... table)
        Export a set of tables to the InformationSchema format.

        Only those foreign keys whose referenced table is also included in the export will be exported.

        This allows for serialising schema meta information as XML using JAXB. See also Constants.XSD_META for details.

      • transactionResult

        <T> T transactionResult​(TransactionalCallable<T> transactional)
        Run a TransactionalCallable in the context of this DSLContext's underlying Scope.configuration()'s Configuration.transactionProvider(), and return the transactional's outcome.

        The argument transactional code should not capture any scope but derive its Configuration from the TransactionalCallable.run(Configuration) argument in order to create new statements.

        Parameters:
        transactional - The transactional code
        Returns:
        The transactional outcome
        Throws:
        java.lang.RuntimeException - any runtime exception thrown by the transactional logic, indicating that a rollback has occurred.
        DataAccessException - any database problem that may have arised when executing the transactional logic, or a wrapper for any checked exception thrown by the transactional logic, indicating that a rollback has occurred.
      • render

        java.lang.String render​(QueryPart part)
        Render a QueryPart in the context of this DSLContext.

        This is the same as calling renderContext().render(part)

        Parameters:
        part - The QueryPart to be rendered
        Returns:
        The rendered SQL
      • renderNamedParams

        java.lang.String renderNamedParams​(QueryPart part)
        Render a QueryPart in the context of this DSLContext, rendering bind variables as named parameters.

        This is the same as calling renderContext().paramType(NAMED).render(part)

        Parameters:
        part - The QueryPart to be rendered
        Returns:
        The rendered SQL
      • renderNamedOrInlinedParams

        java.lang.String renderNamedOrInlinedParams​(QueryPart part)
        Render a QueryPart in the context of this DSLContext, rendering bind variables as named parameters, or inlined parameters if they have no name.

        This is the same as calling renderContext().paramType(NAMED_OR_INLINED).render(part)

        Parameters:
        part - The QueryPart to be rendered
        Returns:
        The rendered SQL
      • renderInlined

        java.lang.String renderInlined​(QueryPart part)
        Render a QueryPart in the context of this DSLContext, inlining all bind variables.

        This is the same as calling renderContext().inline(true).render(part)

        Parameters:
        part - The QueryPart to be rendered
        Returns:
        The rendered SQL
      • extractBindValues

        java.util.List<java.lang.Object> extractBindValues​(QueryPart part)
        Retrieve the bind values that will be bound by a given QueryPart.

        The returned List is immutable. To modify bind values, use extractParams(QueryPart) instead.

        Unlike extractParams(QueryPart), which returns also inlined parameters, this returns only actual bind values that will render an actual bind value as a question mark "?"

      • bindContext

        @Deprecated
        @Internal
        BindContext bindContext​(java.sql.PreparedStatement stmt)
        Deprecated.
        - [#6280] - 3.10 - Do not reuse this method. It will be completely internal with jOOQ 4.0
        Get a new BindContext for the context of this DSLContext.

        This will return an initialised bind context as such:

        BindContext for JOOQ INTERNAL USE only. Avoid referencing it directly

      • bind

        @Deprecated
        int bind​(QueryPart part,
                 java.sql.PreparedStatement stmt)
        Deprecated.
        - [#2662] - 3.2.0 - Do not reuse this method. It will be removed with jOOQ 4.0
      • attach

        void attach​(java.util.Collection<? extends Attachable> attachables)
        Attach this DSLContext's underlying Scope.configuration() to some attachables.
      • query

        @Support
        @PlainSQL
        RowCountQuery query​(SQL sql)
        Create a new query holding plain SQL. There must not be any binding variables contained in the SQL.

        Example:

         String sql = "SET SCHEMA 'abc'";

        NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses!

        Parameters:
        sql - The SQL
        Returns:
        A query wrapping the plain SQL
        See Also:
        SQL
      • query

        @Support
        @PlainSQL
        RowCountQuery query​(java.lang.String sql)
        Create a new query holding plain SQL. There must not be any binding variables contained in the SQL.

        Example:

         String sql = "SET SCHEMA 'abc'";

        NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses!

        Parameters:
        sql - The SQL
        Returns:
        A query wrapping the plain SQL
        See Also:
        SQL
      • query

        @Support
        @PlainSQL
        RowCountQuery query​(java.lang.String sql,
                            java.lang.Object... bindings)
        Create a new query holding plain SQL. There must be as many bind variables contained in the SQL, as passed in the bindings parameter.

        Example:

         String sql = "SET SCHEMA 'abc'";

        NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses!

        Parameters:
        sql - The SQL
        bindings - The bindings
        Returns:
        A query wrapping the plain SQL
        See Also:
        SQL, DSL.sql(String, Object...)
      • query

        @Support
        @PlainSQL
        RowCountQuery query​(java.lang.String sql,
                            QueryPart... parts)
        Create a new query holding plain SQL.

        Unlike query(String, Object...), the SQL passed to this method should not contain any bind variables. Instead, you can pass QueryPart objects to the method which will be rendered at indexed locations of your SQL string as such:

         // The following query
         query("select {0}, {1} from {2}", val(1), inline("test"), name("DUAL"));
        
         // Will render this SQL by default, using SQLDialect.ORACLE:
         select ?, 'test' from "DUAL"
         

        NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses! One way to escape literals is to use DSL.name(String...) and similar methods

        Parameters:
        sql - The SQL clause, containing {numbered placeholders} where query parts can be injected
        parts - The QueryPart objects that are rendered at the {numbered placeholder} locations
        Returns:
        A query wrapping the plain SQL
        See Also:
        SQL, DSL.sql(String, QueryPart...)
      • fetch

        @Support
        @PlainSQL
        Result<Record> fetch​(SQL sql)
                      throws DataAccessException
        Execute a new query holding plain SQL.

        Example (Postgres):

         String sql = "FETCH ALL IN \"<unnamed cursor 1>\"";
        Example (SQLite):

         String sql = "pragma table_info('my_table')";

        NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses!

        Parameters:
        sql - The SQL
        Returns:
        The results from the executed query. This will never be null.
        Throws:
        DataAccessException - if something went wrong executing the query
        See Also:
        SQL
      • fetch

        @Support
        @PlainSQL
        Result<Record> fetch​(java.lang.String sql)
                      throws DataAccessException
        Execute a new query holding plain SQL.

        Example (Postgres):

         String sql = "FETCH ALL IN \"<unnamed cursor 1>\"";
        Example (SQLite):

         String sql = "pragma table_info('my_table')";

        NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses!

        Parameters:
        sql - The SQL
        Returns:
        The results from the executed query. This will never be null.
        Throws:
        DataAccessException - if something went wrong executing the query
        See Also:
        SQL
      • fetch

        @Support
        @PlainSQL
        Result<Record> fetch​(java.lang.String sql,
                             java.lang.Object... bindings)
                      throws DataAccessException
        Execute a new query holding plain SQL.

        There must be as many bind variables contained in the SQL, as passed in the bindings parameter

        Example (Postgres):

         String sql = "FETCH ALL IN \"<unnamed cursor 1>\"";
        Example (SQLite):

         String sql = "pragma table_info('my_table')";

        NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses!

        Parameters:
        sql - The SQL
        bindings - The bindings
        Returns:
        The results from the executed query. This will never be null.
        Throws:
        DataAccessException - if something went wrong executing the query
        See Also:
        SQL, DSL.sql(String, Object...)
      • fetch

        @Support
        @PlainSQL
        Result<Record> fetch​(java.lang.String sql,
                             QueryPart... parts)
                      throws DataAccessException
        Execute a new query holding plain SQL.

        Unlike fetch(String, Object...), the SQL passed to this method should not contain any bind variables. Instead, you can pass QueryPart objects to the method which will be rendered at indexed locations of your SQL string as such:

         // The following query
         fetch("select {0}, {1} from {2}", val(1), inline("test"), name("DUAL"));
        
         // Will execute this SQL by default, using SQLDialect.ORACLE:
         select ?, 'test' from "DUAL"
         

        NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses! One way to escape literals is to use DSL.name(String...) and similar methods

        Parameters:
        sql - The SQL clause, containing {numbered placeholders} where query parts can be injected
        parts - The QueryPart objects that are rendered at the {numbered placeholder} locations
        Returns:
        The results from the executed query. This will never be null.
        Throws:
        DataAccessException - if something went wrong executing the query
        See Also:
        SQL, DSL.sql(String, QueryPart...)
      • fetchLazy

        @Support
        @PlainSQL
        Cursor<Record> fetchLazy​(SQL sql)
                          throws DataAccessException
        Execute a new query holding plain SQL and "lazily" return the generated result.

        The returned Cursor holds a reference to the executed PreparedStatement and the associated ResultSet. Data can be fetched (or iterated over) lazily, fetching records from the ResultSet one by one.

        Example (Postgres):

         String sql = "FETCH ALL IN \"<unnamed cursor 1>\"";
        Example (SQLite):

         String sql = "pragma table_info('my_table')";

        NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses!

        Parameters:
        sql - The SQL
        Returns:
        The cursor. This will never be null.
        Throws:
        DataAccessException - if something went wrong executing the query
        See Also:
        SQL
      • fetchLazy

        @Support
        @PlainSQL
        Cursor<Record> fetchLazy​(java.lang.String sql)
                          throws DataAccessException
        Execute a new query holding plain SQL and "lazily" return the generated result.

        The returned Cursor holds a reference to the executed PreparedStatement and the associated ResultSet. Data can be fetched (or iterated over) lazily, fetching records from the ResultSet one by one.

        Example (Postgres):

         String sql = "FETCH ALL IN \"<unnamed cursor 1>\"";
        Example (SQLite):

         String sql = "pragma table_info('my_table')";

        NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses!

        Parameters:
        sql - The SQL
        Returns:
        The cursor. This will never be null.
        Throws:
        DataAccessException - if something went wrong executing the query
        See Also:
        SQL
      • fetchLazy

        @Support
        @PlainSQL
        Cursor<Record> fetchLazy​(java.lang.String sql,
                                 java.lang.Object... bindings)
                          throws DataAccessException
        Execute a new query holding plain SQL and "lazily" return the generated result.

        There must be as many bind variables contained in the SQL, as passed in the bindings parameter

        The returned Cursor holds a reference to the executed PreparedStatement and the associated ResultSet. Data can be fetched (or iterated over) lazily, fetching records from the ResultSet one by one.

        Example (Postgres):

         String sql = "FETCH ALL IN \"<unnamed cursor 1>\"";
        Example (SQLite):

         String sql = "pragma table_info('my_table')";

        NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses!

        Parameters:
        sql - The SQL
        bindings - The bindings
        Returns:
        The cursor. This will never be null.
        Throws:
        DataAccessException - if something went wrong executing the query
        See Also:
        SQL, DSL.sql(String, Object...)
      • fetchLazy

        @Support
        @PlainSQL
        Cursor<Record> fetchLazy​(java.lang.String sql,
                                 QueryPart... parts)
                          throws DataAccessException
        Execute a new query holding plain SQL and "lazily" return the generated result.

        The returned Cursor holds a reference to the executed PreparedStatement and the associated ResultSet. Data can be fetched (or iterated over) lazily, fetching records from the ResultSet one by one.

        Unlike fetchLazy(String, Object...), the SQL passed to this method should not contain any bind variables. Instead, you can pass QueryPart objects to the method which will be rendered at indexed locations of your SQL string as such:

         // The following query
         fetchLazy("select {0}, {1} from {2}", val(1), inline("test"), name("DUAL"));
        
         // Will execute this SQL by default, using SQLDialect.ORACLE:
         select ?, 'test' from "DUAL"
         

        NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses! One way to escape literals is to use DSL.name(String...) and similar methods

        Parameters:
        sql - The SQL clause, containing {numbered placeholders} where query parts can be injected
        parts - The QueryPart objects that are rendered at the {numbered placeholder} locations
        Returns:
        The cursor. This will never be null.
        Throws:
        DataAccessException - if something went wrong executing the query
        See Also:
        SQL, DSL.sql(String, QueryPart...)
      • fetchAsync

        @Support
        @PlainSQL
        java.util.concurrent.CompletionStage<Result<Record>> fetchAsync​(SQL sql)
        Fetch results in a new CompletionStage.

        The result is asynchronously completed by a task running in an Executor provided by the Scope.configuration()'s Configuration.executorProvider().

        Example (Postgres):

         String sql = "FETCH ALL IN \"<unnamed cursor 1>\"";
        Example (SQLite):

         String sql = "pragma table_info('my_table')";

        NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses!

        Parameters:
        sql - The SQL
        Returns:
        The completion stage. The completed result will never be null.
        See Also:
        SQL
      • fetchAsync

        @Support
        @PlainSQL
        java.util.concurrent.CompletionStage<Result<Record>> fetchAsync​(java.lang.String sql)
        Fetch results in a new CompletionStage.

        The result is asynchronously completed by a task running in an Executor provided by the Scope.configuration()'s Configuration.executorProvider().

        Example (Postgres):

         String sql = "FETCH ALL IN \"<unnamed cursor 1>\"";
        Example (SQLite):

         String sql = "pragma table_info('my_table')";

        NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses!

        Parameters:
        sql - The SQL
        Returns:
        The completion stage. The completed result will never be null.
        See Also:
        SQL
      • fetchAsync

        @Support
        @PlainSQL
        java.util.concurrent.CompletionStage<Result<Record>> fetchAsync​(java.lang.String sql,
                                                                        java.lang.Object... bindings)
        Fetch results in a new CompletionStage.

        The result is asynchronously completed by a task running in an Executor provided by the Scope.configuration()'s Configuration.executorProvider().

        There must be as many bind variables contained in the SQL, as passed in the bindings parameter

        Example (Postgres):

         String sql = "FETCH ALL IN \"<unnamed cursor 1>\"";
        Example (SQLite):

         String sql = "pragma table_info('my_table')";

        NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses!

        Parameters:
        sql - The SQL
        bindings - The bindings
        Returns:
        The completion stage. The completed result will never be null.
        See Also:
        SQL, DSL.sql(String, Object...)
      • fetchAsync

        @Support
        @PlainSQL
        java.util.concurrent.CompletionStage<Result<Record>> fetchAsync​(java.lang.String sql,
                                                                        QueryPart... parts)
        Fetch results in a new CompletionStage.

        The result is asynchronously completed by a task running in an Executor provided by the Scope.configuration()'s Configuration.executorProvider().

        Unlike fetchLazy(String, Object...), the SQL passed to this method should not contain any bind variables. Instead, you can pass QueryPart objects to the method which will be rendered at indexed locations of your SQL string as such:

         // The following query
         fetchLazy("select {0}, {1} from {2}", val(1), inline("test"), name("DUAL"));
        
         // Will execute this SQL by default, using SQLDialect.ORACLE:
         select ?, 'test' from "DUAL"
         

        NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses! One way to escape literals is to use DSL.name(String...) and similar methods

        Parameters:
        sql - The SQL clause, containing {numbered placeholders} where query parts can be injected
        parts - The QueryPart objects that are rendered at the {numbered placeholder} locations
        Returns:
        The completion stage. The completed result will never be null.
        See Also:
        SQL, DSL.sql(String, QueryPart...)
      • fetchAsync

        @Support
        @PlainSQL
        java.util.concurrent.CompletionStage<Result<Record>> fetchAsync​(java.util.concurrent.Executor executor,
                                                                        SQL sql)
        Fetch results in a new CompletionStage that is asynchronously completed by a task running in the given executor.

        Example (Postgres):

         String sql = "FETCH ALL IN \"<unnamed cursor 1>\"";
        Example (SQLite):

         String sql = "pragma table_info('my_table')";

        NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses!

        Parameters:
        sql - The SQL
        Returns:
        The completion stage. The completed result will never be null.
        See Also:
        SQL
      • fetchAsync

        @Support
        @PlainSQL
        java.util.concurrent.CompletionStage<Result<Record>> fetchAsync​(java.util.concurrent.Executor executor,
                                                                        java.lang.String sql)
        Fetch results in a new CompletionStage that is asynchronously completed by a task running in the given executor.

        Example (Postgres):

         String sql = "FETCH ALL IN \"<unnamed cursor 1>\"";
        Example (SQLite):

         String sql = "pragma table_info('my_table')";

        NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses!

        Parameters:
        sql - The SQL
        Returns:
        The completion stage. The completed result will never be null.
        See Also:
        SQL
      • fetchAsync

        @Support
        @PlainSQL
        java.util.concurrent.CompletionStage<Result<Record>> fetchAsync​(java.util.concurrent.Executor executor,
                                                                        java.lang.String sql,
                                                                        java.lang.Object... bindings)
        Fetch results in a new CompletionStage that is asynchronously completed by a task running in the given executor.

        There must be as many bind variables contained in the SQL, as passed in the bindings parameter

        Example (Postgres):

         String sql = "FETCH ALL IN \"<unnamed cursor 1>\"";
        Example (SQLite):

         String sql = "pragma table_info('my_table')";

        NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses!

        Parameters:
        sql - The SQL
        bindings - The bindings
        Returns:
        The completion stage. The completed result will never be null.
        See Also:
        SQL, DSL.sql(String, Object...)
      • fetchAsync

        @Support
        @PlainSQL
        java.util.concurrent.CompletionStage<Result<Record>> fetchAsync​(java.util.concurrent.Executor executor,
                                                                        java.lang.String sql,
                                                                        QueryPart... parts)
        Fetch results in a new CompletionStage that is asynchronously completed by a task running in the given executor.

        Unlike fetchLazy(String, Object...), the SQL passed to this method should not contain any bind variables. Instead, you can pass QueryPart objects to the method which will be rendered at indexed locations of your SQL string as such:

         // The following query
         fetchLazy("select {0}, {1} from {2}", val(1), inline("test"), name("DUAL"));
        
         // Will execute this SQL by default, using SQLDialect.ORACLE:
         select ?, 'test' from "DUAL"
         

        NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses! One way to escape literals is to use DSL.name(String...) and similar methods

        Parameters:
        sql - The SQL clause, containing {numbered placeholders} where query parts can be injected
        parts - The QueryPart objects that are rendered at the {numbered placeholder} locations
        Returns:
        The completion stage. The completed result will never be null.
        See Also:
        SQL, DSL.sql(String, QueryPart...)
      • fetchStream

        @Support
        @PlainSQL
        java.util.stream.Stream<Record> fetchStream​(SQL sql)
                                             throws DataAccessException
        Execute a new query holding plain SQL and "lazily" return the generated result.

        The returned Stream holds a reference to the executed PreparedStatement and the associated ResultSet. Data can be fetched (or iterated over) lazily, fetching records from the ResultSet one by one.

        Example (Postgres):

         String sql = "FETCH ALL IN \"<unnamed cursor 1>\"";
        Example (SQLite):

         String sql = "pragma table_info('my_table')";

        NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses!

        Parameters:
        sql - The SQL
        Returns:
        The results from the executed query. This is never null, even if the database returns no ResultSet
        Throws:
        DataAccessException - if something went wrong executing the query
        See Also:
        SQL
      • fetchStream

        @Support
        @PlainSQL
        java.util.stream.Stream<Record> fetchStream​(java.lang.String sql)
                                             throws DataAccessException
        Execute a new query holding plain SQL and "lazily" return the generated result.

        The returned Stream holds a reference to the executed PreparedStatement and the associated ResultSet. Data can be fetched (or iterated over) lazily, fetching records from the ResultSet one by one.

        Example (Postgres):

         String sql = "FETCH ALL IN \"<unnamed cursor 1>\"";
        Example (SQLite):

         String sql = "pragma table_info('my_table')";

        NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses!

        Parameters:
        sql - The SQL
        Returns:
        The results from the executed query. This is never null, even if the database returns no ResultSet
        Throws:
        DataAccessException - if something went wrong executing the query
        See Also:
        SQL
      • fetchStream

        @Support
        @PlainSQL
        java.util.stream.Stream<Record> fetchStream​(java.lang.String sql,
                                                    java.lang.Object... bindings)
                                             throws DataAccessException
        Execute a new query holding plain SQL and "lazily" return the generated result.

        There must be as many bind variables contained in the SQL, as passed in the bindings parameter

        The returned Stream holds a reference to the executed PreparedStatement and the associated ResultSet. Data can be fetched (or iterated over) lazily, fetching records from the ResultSet one by one.

        Example (Postgres):

         String sql = "FETCH ALL IN \"<unnamed cursor 1>\"";
        Example (SQLite):

         String sql = "pragma table_info('my_table')";

        NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses!

        Parameters:
        sql - The SQL
        bindings - The bindings
        Returns:
        The results from the executed query. This is never null, even if the database returns no ResultSet
        Throws:
        DataAccessException - if something went wrong executing the query
        See Also:
        SQL, DSL.sql(String, Object...)
      • fetchStream

        @Support
        @PlainSQL
        java.util.stream.Stream<Record> fetchStream​(java.lang.String sql,
                                                    QueryPart... parts)
                                             throws DataAccessException
        Execute a new query holding plain SQL and "lazily" return the generated result.

        The returned Stream holds a reference to the executed PreparedStatement and the associated ResultSet. Data can be fetched (or iterated over) lazily, fetching records from the ResultSet one by one.

        Unlike fetchStream(String, Object...), the SQL passed to this method should not contain any bind variables. Instead, you can pass QueryPart objects to the method which will be rendered at indexed locations of your SQL string as such:

         // The following query
         fetchLazy("select {0}, {1} from {2}", val(1), inline("test"), name("DUAL"));
        
         // Will execute this SQL by default, using SQLDialect.ORACLE:
         select ?, 'test' from "DUAL"
         

        NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses! One way to escape literals is to use DSL.name(String...) and similar methods

        Parameters:
        sql - The SQL clause, containing {numbered placeholders} where query parts can be injected
        parts - The QueryPart objects that are rendered at the {numbered placeholder} locations
        Returns:
        The results from the executed query. This is never null, even if the database returns no ResultSet
        Throws:
        DataAccessException - if something went wrong executing the query
        See Also:
        SQL, DSL.sql(String, QueryPart...)
      • fetchMany

        @Support
        @PlainSQL
        Results fetchMany​(SQL sql)
                   throws DataAccessException
        Execute a new query holding plain SQL, possibly returning several result sets.

        Example (Sybase ASE):

         String sql = "sp_help 'my_table'";

        NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses!

        Parameters:
        sql - The SQL
        Returns:
        The results. This will never be null.
        Throws:
        DataAccessException - if something went wrong executing the query
        See Also:
        SQL
      • fetchMany

        @Support
        @PlainSQL
        Results fetchMany​(java.lang.String sql)
                   throws DataAccessException
        Execute a new query holding plain SQL, possibly returning several result sets.

        Example (Sybase ASE):

         String sql = "sp_help 'my_table'";

        NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses!

        Parameters:
        sql - The SQL
        Returns:
        The results. This will never be null.
        Throws:
        DataAccessException - if something went wrong executing the query
        See Also:
        SQL
      • fetchMany

        @Support
        @PlainSQL
        Results fetchMany​(java.lang.String sql,
                          java.lang.Object... bindings)
                   throws DataAccessException
        Execute a new query holding plain SQL, possibly returning several result sets.

        There must be as many bind variables contained in the SQL, as passed in the bindings parameter

        Example (Sybase ASE):

         String sql = "sp_help 'my_table'";

        NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses!

        Parameters:
        sql - The SQL
        bindings - The bindings
        Returns:
        The results. This will never be null.
        Throws:
        DataAccessException - if something went wrong executing the query
        See Also:
        SQL, DSL.sql(String, Object...)
      • fetchMany

        @Support
        @PlainSQL
        Results fetchMany​(java.lang.String sql,
                          QueryPart... parts)
                   throws DataAccessException
        Execute a new query holding plain SQL, possibly returning several result sets.

        Unlike fetchMany(String, Object...), the SQL passed to this method should not contain any bind variables. Instead, you can pass QueryPart objects to the method which will be rendered at indexed locations of your SQL string as such:

         // The following query
         fetchMany("select {0}, {1} from {2}", val(1), inline("test"), name("DUAL"));
        
         // Will execute this SQL by default, using SQLDialect.ORACLE:
         select ?, 'test' from "DUAL"
         

        NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses! One way to escape literals is to use DSL.name(String...) and similar methods

        Parameters:
        sql - The SQL clause, containing {numbered placeholders} where query parts can be injected
        parts - The QueryPart objects that are rendered at the {numbered placeholder} locations
        Returns:
        The results. This will never be null.
        Throws:
        DataAccessException - if something went wrong executing the query
        See Also:
        SQL, DSL.sql(String, QueryPart...)
      • fetchOne

        @Support
        @PlainSQL
        Record fetchOne​(SQL sql)
                 throws DataAccessException,
                        TooManyRowsException
        Execute a new query holding plain SQL.

        Example (Postgres):

         String sql = "FETCH ALL IN \"<unnamed cursor 1>\"";
        Example (SQLite):

         String sql = "pragma table_info('my_table')";

        NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses!

        Parameters:
        sql - The SQL
        Returns:
        The record or null, if no record was found.
        Throws:
        DataAccessException - if something went wrong executing the query
        TooManyRowsException - if the query returned more than one record
        See Also:
        SQL
      • fetchOne

        @Support
        @PlainSQL
        Record fetchOne​(java.lang.String sql)
                 throws DataAccessException,
                        TooManyRowsException
        Execute a new query holding plain SQL.

        Example (Postgres):

         String sql = "FETCH ALL IN \"<unnamed cursor 1>\"";
        Example (SQLite):

         String sql = "pragma table_info('my_table')";

        NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses!

        Parameters:
        sql - The SQL
        Returns:
        The record or null, if no record was found.
        Throws:
        DataAccessException - if something went wrong executing the query
        TooManyRowsException - if the query returned more than one record
        See Also:
        SQL
      • fetchOne

        @Support
        @PlainSQL
        Record fetchOne​(java.lang.String sql,
                        java.lang.Object... bindings)
                 throws DataAccessException,
                        TooManyRowsException
        Execute a new query holding plain SQL.

        There must be as many bind variables contained in the SQL, as passed in the bindings parameter

        Example (Postgres):

         String sql = "FETCH ALL IN \"<unnamed cursor 1>\"";
        Example (SQLite):

         String sql = "pragma table_info('my_table')";

        NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses!

        Parameters:
        sql - The SQL
        bindings - The bindings
        Returns:
        The record or null, if no record was found.
        Throws:
        DataAccessException - if something went wrong executing the query
        TooManyRowsException - if the query returned more than one record
        See Also:
        SQL, DSL.sql(String, Object...)
      • fetchOne

        @Support
        @PlainSQL
        Record fetchOne​(java.lang.String sql,
                        QueryPart... parts)
                 throws DataAccessException,
                        TooManyRowsException
        Execute a new query holding plain SQL.

        Unlike fetchOne(String, Object...), the SQL passed to this method should not contain any bind variables. Instead, you can pass QueryPart objects to the method which will be rendered at indexed locations of your SQL string as such:

         // The following query
         fetchOne("select {0}, {1} from {2}", val(1), inline("test"), name("DUAL"));
        
         // Will execute this SQL by default, using SQLDialect.ORACLE:
         select ?, 'test' from "DUAL"
         

        NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses! One way to escape literals is to use DSL.name(String...) and similar methods

        Parameters:
        sql - The SQL clause, containing {numbered placeholders} where query parts can be injected
        parts - The QueryPart objects that are rendered at the {numbered placeholder} locations
        Returns:
        The record or null, if no record was found.
        Throws:
        DataAccessException - if something went wrong executing the query
        TooManyRowsException - if the query returned more than one record
        See Also:
        SQL, DSL.sql(String, QueryPart...)
      • fetchSingle

        @Support
        @PlainSQL
        Record fetchSingle​(SQL sql)
                    throws DataAccessException,
                           NoDataFoundException,
                           TooManyRowsException
        Execute a new query holding plain SQL.

        Example (Postgres):

         String sql = "FETCH ALL IN \"<unnamed cursor 1>\"";
        Example (SQLite):

         String sql = "pragma table_info('my_table')";

        NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses!

        Parameters:
        sql - The SQL
        Returns:
        The record. This is never null.
        Throws:
        DataAccessException - if something went wrong executing the query
        NoDataFoundException - if the query returned no rows
        TooManyRowsException - if the query returned more than one record
        See Also:
        SQL
      • fetchSingle

        @Support
        @PlainSQL
        Record fetchSingle​(java.lang.String sql)
                    throws DataAccessException,
                           NoDataFoundException,
                           TooManyRowsException
        Execute a new query holding plain SQL.

        Example (Postgres):

         String sql = "FETCH ALL IN \"<unnamed cursor 1>\"";
        Example (SQLite):

         String sql = "pragma table_info('my_table')";

        NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses!

        Parameters:
        sql - The SQL
        Returns:
        The record. This is never null.
        Throws:
        DataAccessException - if something went wrong executing the query
        NoDataFoundException - if the query returned no rows
        TooManyRowsException - if the query returned more than one record
        See Also:
        SQL
      • fetchSingle

        @Support
        @PlainSQL
        Record fetchSingle​(java.lang.String sql,
                           java.lang.Object... bindings)
                    throws DataAccessException,
                           NoDataFoundException,
                           TooManyRowsException
        Execute a new query holding plain SQL.

        There must be as many bind variables contained in the SQL, as passed in the bindings parameter

        Example (Postgres):

         String sql = "FETCH ALL IN \"<unnamed cursor 1>\"";
        Example (SQLite):

         String sql = "pragma table_info('my_table')";

        NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses!

        Parameters:
        sql - The SQL
        bindings - The bindings
        Returns:
        The record. This is never null.
        Throws:
        DataAccessException - if something went wrong executing the query
        NoDataFoundException - if the query returned no rows
        TooManyRowsException - if the query returned more than one record
        See Also:
        SQL, DSL.sql(String, Object...)
      • fetchSingle

        @Support
        @PlainSQL
        Record fetchSingle​(java.lang.String sql,
                           QueryPart... parts)
                    throws DataAccessException,
                           NoDataFoundException,
                           TooManyRowsException
        Execute a new query holding plain SQL.

        Unlike fetchOne(String, Object...), the SQL passed to this method should not contain any bind variables. Instead, you can pass QueryPart objects to the method which will be rendered at indexed locations of your SQL string as such:

         // The following query
         fetchOne("select {0}, {1} from {2}", val(1), inline("test"), name("DUAL"));
        
         // Will execute this SQL by default, using SQLDialect.ORACLE:
         select ?, 'test' from "DUAL"
         

        NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses! One way to escape literals is to use DSL.name(String...) and similar methods

        Parameters:
        sql - The SQL clause, containing {numbered placeholders} where query parts can be injected
        parts - The QueryPart objects that are rendered at the {numbered placeholder} locations
        Returns:
        The record. This is never null.
        Throws:
        DataAccessException - if something went wrong executing the query
        NoDataFoundException - if the query returned no rows
        TooManyRowsException - if the query returned more than one record
        See Also:
        SQL, DSL.sql(String, QueryPart...)
      • fetchOptional

        @Support
        @PlainSQL
        java.util.Optional<Record> fetchOptional​(SQL sql)
                                          throws DataAccessException,
                                                 TooManyRowsException
        Execute a new query holding plain SQL.

        Example (Postgres):

         String sql = "FETCH ALL IN \"<unnamed cursor 1>\"";
        Example (SQLite):

         String sql = "pragma table_info('my_table')";

        NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses!

        Parameters:
        sql - The SQL
        Returns:
        The results from the executed query
        Throws:
        DataAccessException - if something went wrong executing the query
        TooManyRowsException - if the query returned more than one record
        See Also:
        SQL
      • fetchOptional

        @Support
        @PlainSQL
        java.util.Optional<Record> fetchOptional​(java.lang.String sql)
                                          throws DataAccessException,
                                                 TooManyRowsException
        Execute a new query holding plain SQL.

        Example (Postgres):

         String sql = "FETCH ALL IN \"<unnamed cursor 1>\"";
        Example (SQLite):

         String sql = "pragma table_info('my_table')";

        NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses!

        Parameters:
        sql - The SQL
        Returns:
        The results from the executed query
        Throws:
        DataAccessException - if something went wrong executing the query
        TooManyRowsException - if the query returned more than one record
        See Also:
        SQL
      • fetchOptional

        @Support
        @PlainSQL
        java.util.Optional<Record> fetchOptional​(java.lang.String sql,
                                                 java.lang.Object... bindings)
                                          throws DataAccessException,
                                                 TooManyRowsException
        Execute a new query holding plain SQL.

        There must be as many bind variables contained in the SQL, as passed in the bindings parameter

        Example (Postgres):

         String sql = "FETCH ALL IN \"<unnamed cursor 1>\"";
        Example (SQLite):

         String sql = "pragma table_info('my_table')";

        NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses!

        Parameters:
        sql - The SQL
        bindings - The bindings
        Returns:
        The results from the executed query
        Throws:
        DataAccessException - if something went wrong executing the query
        TooManyRowsException - if the query returned more than one record
        See Also:
        SQL, DSL.sql(String, Object...)
      • fetchOptional

        @Support
        @PlainSQL
        java.util.Optional<Record> fetchOptional​(java.lang.String sql,
                                                 QueryPart... parts)
                                          throws DataAccessException,
                                                 TooManyRowsException
        Execute a new query holding plain SQL.

        Unlike fetchOne(String, Object...), the SQL passed to this method should not contain any bind variables. Instead, you can pass QueryPart objects to the method which will be rendered at indexed locations of your SQL string as such:

         // The following query
         fetchOne("select {0}, {1} from {2}", val(1), inline("test"), name("DUAL"));
        
         // Will execute this SQL by default, using SQLDialect.ORACLE:
         select ?, 'test' from "DUAL"
         

        NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses! One way to escape literals is to use DSL.name(String...) and similar methods

        Parameters:
        sql - The SQL clause, containing {numbered placeholders} where query parts can be injected
        parts - The QueryPart objects that are rendered at the {numbered placeholder} locations
        Returns:
        The results from the executed query
        Throws:
        DataAccessException - if something went wrong executing the query
        TooManyRowsException - if the query returned more than one record
        See Also:
        SQL, DSL.sql(String, QueryPart...)
      • fetchValue

        @Support
        @PlainSQL
        java.lang.Object fetchValue​(SQL sql)
                             throws DataAccessException,
                                    TooManyRowsException,
                                    InvalidResultException
        Execute a new query holding plain SQL.

        Example (Postgres):

         String sql = "FETCH ALL IN \"<unnamed cursor 1>\"";
        Example (SQLite):

         String sql = "pragma table_info('my_table')";

        NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses!

        Parameters:
        sql - The SQL
        Returns:
        The value or null, if no record was found.
        Throws:
        DataAccessException - if something went wrong executing the query
        TooManyRowsException - if the query returned more than one record
        InvalidResultException - if the query returned a record with more than one value
        See Also:
        SQL
      • fetchValue

        @Support
        @PlainSQL
        java.lang.Object fetchValue​(java.lang.String sql)
                             throws DataAccessException,
                                    TooManyRowsException,
                                    InvalidResultException
        Execute a new query holding plain SQL.

        Example (Postgres):

         String sql = "FETCH ALL IN \"<unnamed cursor 1>\"";
        Example (SQLite):

         String sql = "pragma table_info('my_table')";

        NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses!

        Parameters:
        sql - The SQL
        Returns:
        The value or null, if no record was found.
        Throws:
        DataAccessException - if something went wrong executing the query
        TooManyRowsException - if the query returned more than one record
        InvalidResultException - if the query returned a record with more than one value
        See Also:
        SQL
      • fetchValue

        @Support
        @PlainSQL
        java.lang.Object fetchValue​(java.lang.String sql,
                                    java.lang.Object... bindings)
                             throws DataAccessException,
                                    TooManyRowsException,
                                    InvalidResultException
        Execute a new query holding plain SQL.

        There must be as many bind variables contained in the SQL, as passed in the bindings parameter

        Example (Postgres):

         String sql = "FETCH ALL IN \"<unnamed cursor 1>\"";
        Example (SQLite):

         String sql = "pragma table_info('my_table')";

        NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses!

        Parameters:
        sql - The SQL
        bindings - The bindings
        Returns:
        The value or null, if no record was found.
        Throws:
        DataAccessException - if something went wrong executing the query
        TooManyRowsException - if the query returned more than one record
        InvalidResultException - if the query returned a record with more than one value
        See Also:
        SQL, DSL.sql(String, Object...)
      • fetchValue

        @Support
        @PlainSQL
        java.lang.Object fetchValue​(java.lang.String sql,
                                    QueryPart... parts)
                             throws DataAccessException,
                                    TooManyRowsException,
                                    InvalidResultException
        Execute a new query holding plain SQL.

        Unlike fetchValue(String, Object...), the SQL passed to this method should not contain any bind variables. Instead, you can pass QueryPart objects to the method which will be rendered at indexed locations of your SQL string as such:

         // The following query
         fetchOne("select {0}, {1} from {2}", val(1), inline("test"), name("DUAL"));
        
         // Will execute this SQL by default, using SQLDialect.ORACLE:
         select ?, 'test' from "DUAL"
         

        NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses! One way to escape literals is to use DSL.name(String...) and similar methods

        Parameters:
        sql - The SQL clause, containing {numbered placeholders} where query parts can be injected
        parts - The QueryPart objects that are rendered at the {numbered placeholder} locations
        Returns:
        The value or null, if no record was found.
        Throws:
        DataAccessException - if something went wrong executing the query
        TooManyRowsException - if the query returned more than one record
        InvalidResultException - if the query returned a record with more than one value
        See Also:
        SQL, DSL.sql(String, QueryPart...)
      • fetchOptionalValue

        @Support
        @PlainSQL
        java.util.Optional<?> fetchOptionalValue​(SQL sql)
                                          throws DataAccessException,
                                                 TooManyRowsException,
                                                 InvalidResultException
        Execute a new query holding plain SQL.

        Example (Postgres):

         String sql = "FETCH ALL IN \"<unnamed cursor 1>\"";
        Example (SQLite):

         String sql = "pragma table_info('my_table')";

        NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses!

        Parameters:
        sql - The SQL
        Returns:
        The result value from the executed query
        Throws:
        DataAccessException - if something went wrong executing the query
        TooManyRowsException - if the query returned more than one record
        InvalidResultException - if the query returned a record with more than one value
        See Also:
        SQL
      • fetchOptionalValue

        @Support
        @PlainSQL
        java.util.Optional<?> fetchOptionalValue​(java.lang.String sql)
                                          throws DataAccessException,
                                                 TooManyRowsException,
                                                 InvalidResultException
        Execute a new query holding plain SQL.

        Example (Postgres):

         String sql = "FETCH ALL IN \"<unnamed cursor 1>\"";
        Example (SQLite):

         String sql = "pragma table_info('my_table')";

        NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses!

        Parameters:
        sql - The SQL
        Returns:
        The result value from the executed query
        Throws:
        DataAccessException - if something went wrong executing the query
        TooManyRowsException - if the query returned more than one record
        InvalidResultException - if the query returned a record with more than one value
        See Also:
        SQL
      • fetchOptionalValue

        @Support
        @PlainSQL
        java.util.Optional<?> fetchOptionalValue​(java.lang.String sql,
                                                 java.lang.Object... bindings)
                                          throws DataAccessException,
                                                 TooManyRowsException,
                                                 InvalidResultException
        Execute a new query holding plain SQL.

        There must be as many bind variables contained in the SQL, as passed in the bindings parameter

        Example (Postgres):

         String sql = "FETCH ALL IN \"<unnamed cursor 1>\"";
        Example (SQLite):

         String sql = "pragma table_info('my_table')";

        NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses!

        Parameters:
        sql - The SQL
        bindings - The bindings
        Returns:
        The results from the executed query
        Throws:
        DataAccessException - if something went wrong executing the query
        TooManyRowsException - if the query returned more than one record
        InvalidResultException - if the query returned a record with more than one value
        See Also:
        SQL, DSL.sql(String, Object...)
      • fetchOptionalValue

        @Support
        @PlainSQL
        java.util.Optional<?> fetchOptionalValue​(java.lang.String sql,
                                                 QueryPart... parts)
                                          throws DataAccessException,
                                                 TooManyRowsException,
                                                 InvalidResultException
        Execute a new query holding plain SQL.

        Unlike fetchValue(String, Object...), the SQL passed to this method should not contain any bind variables. Instead, you can pass QueryPart objects to the method which will be rendered at indexed locations of your SQL string as such:

         // The following query
         fetchOne("select {0}, {1} from {2}", val(1), inline("test"), name("DUAL"));
        
         // Will execute this SQL by default, using SQLDialect.ORACLE:
         select ?, 'test' from "DUAL"
         

        NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses! One way to escape literals is to use DSL.name(String...) and similar methods

        Parameters:
        sql - The SQL clause, containing {numbered placeholders} where query parts can be injected
        parts - The QueryPart objects that are rendered at the {numbered placeholder} locations
        Returns:
        The results from the executed query
        Throws:
        DataAccessException - if something went wrong executing the query
        TooManyRowsException - if the query returned more than one record
        InvalidResultException - if the query returned a record with more than one value
        See Also:
        SQL, DSL.sql(String, QueryPart...)
      • fetchValues

        @Support
        @PlainSQL
        java.util.List<?> fetchValues​(SQL sql)
                               throws DataAccessException,
                                      InvalidResultException
        Execute a new query holding plain SQL.

        Example (Postgres):

         String sql = "FETCH ALL IN \"<unnamed cursor 1>\"";
        Example (SQLite):

         String sql = "pragma table_info('my_table')";

        NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses!

        Parameters:
        sql - The SQL
        Returns:
        The values. This will never be null.
        Throws:
        DataAccessException - if something went wrong executing the query
        InvalidResultException - if the query returned a record with more than one value
        See Also:
        SQL
      • fetchValues

        @Support
        @PlainSQL
        java.util.List<?> fetchValues​(java.lang.String sql)
                               throws DataAccessException,
                                      InvalidResultException
        Execute a new query holding plain SQL.

        Example (Postgres):

         String sql = "FETCH ALL IN \"<unnamed cursor 1>\"";
        Example (SQLite):

         String sql = "pragma table_info('my_table')";

        NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses!

        Parameters:
        sql - The SQL
        Returns:
        The values. This will never be null.
        Throws:
        DataAccessException - if something went wrong executing the query
        InvalidResultException - if the query returned a record with more than one value
        See Also:
        SQL
      • fetchValues

        @Support
        @PlainSQL
        java.util.List<?> fetchValues​(java.lang.String sql,
                                      java.lang.Object... bindings)
                               throws DataAccessException,
                                      InvalidResultException
        Execute a new query holding plain SQL.

        There must be as many bind variables contained in the SQL, as passed in the bindings parameter

        Example (Postgres):

         String sql = "FETCH ALL IN \"<unnamed cursor 1>\"";
        Example (SQLite):

         String sql = "pragma table_info('my_table')";

        NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses!

        Parameters:
        sql - The SQL
        bindings - The bindings
        Returns:
        The values. This will never be null.
        Throws:
        DataAccessException - if something went wrong executing the query
        InvalidResultException - if the query returned a record with more than one value
        See Also:
        SQL, DSL.sql(String, Object...)
      • fetchValues

        @Support
        @PlainSQL
        java.util.List<?> fetchValues​(java.lang.String sql,
                                      QueryPart... parts)
                               throws DataAccessException,
                                      InvalidResultException
        Execute a new query holding plain SQL.

        Unlike fetchValue(String, Object...), the SQL passed to this method should not contain any bind variables. Instead, you can pass QueryPart objects to the method which will be rendered at indexed locations of your SQL string as such:

         // The following query
         fetchOne("select {0}, {1} from {2}", val(1), inline("test"), name("DUAL"));
        
         // Will execute this SQL by default, using SQLDialect.ORACLE:
         select ?, 'test' from "DUAL"
         

        NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses! One way to escape literals is to use DSL.name(String...) and similar methods

        Parameters:
        sql - The SQL clause, containing {numbered placeholders} where query parts can be injected
        parts - The QueryPart objects that are rendered at the {numbered placeholder} locations
        Returns:
        The values. This will never be null.
        Throws:
        DataAccessException - if something went wrong executing the query
        InvalidResultException - if the query returned a record with more than one value
        See Also:
        SQL, DSL.sql(String, QueryPart...)
      • execute

        @Support
        @PlainSQL
        int execute​(SQL sql)
             throws DataAccessException
        Execute a query holding plain SQL.

        NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses!

        Parameters:
        sql - The SQL
        Returns:
        The results from the executed query
        Throws:
        DataAccessException - if something went wrong executing the query
        See Also:
        SQL
      • execute

        @Support
        @PlainSQL
        int execute​(java.lang.String sql)
             throws DataAccessException
        Execute a query holding plain SQL.

        NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses!

        Parameters:
        sql - The SQL
        Returns:
        The results from the executed query
        Throws:
        DataAccessException - if something went wrong executing the query
        See Also:
        SQL
      • execute

        @Support
        @PlainSQL
        int execute​(java.lang.String sql,
                    java.lang.Object... bindings)
             throws DataAccessException
        Execute a new query holding plain SQL.

        There must be as many bind variables contained in the SQL, as passed in the bindings parameter

        NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses!

        Parameters:
        sql - The SQL
        bindings - The bindings
        Returns:
        The results from the executed query
        Throws:
        DataAccessException - if something went wrong executing the query
        See Also:
        SQL, DSL.sql(String, Object...)
      • execute

        @Support
        @PlainSQL
        int execute​(java.lang.String sql,
                    QueryPart... parts)
             throws DataAccessException
        Execute a new query holding plain SQL.

        Unlike execute(String, Object...), the SQL passed to this method should not contain any bind variables. Instead, you can pass QueryPart objects to the method which will be rendered at indexed locations of your SQL string as such:

         // The following query
         execute("select {0}, {1} from {2}", val(1), inline("test"), name("DUAL"));
        
         // Will execute this SQL by default, using SQLDialect.ORACLE:
         select ?, 'test' from "DUAL"
         

        NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses! One way to escape literals is to use DSL.name(String...) and similar methods

        Parameters:
        sql - The SQL clause, containing {numbered placeholders} where query parts can be injected
        parts - The QueryPart objects that are rendered at the {numbered placeholder} locations
        Returns:
        The results from the executed query
        Throws:
        DataAccessException - if something went wrong executing the query
        See Also:
        SQL, DSL.sql(String, QueryPart...)
      • resultQuery

        @Support
        @PlainSQL
        ResultQuery<Record> resultQuery​(SQL sql)
        Create a new query holding plain SQL.

        There must not be any bind variables contained in the SQL

        Use this method, when you want to take advantage of the many ways to fetch results in jOOQ, using ResultQuery. Some examples:

        ResultQuery.fetchLazy() Open a cursor and fetch records one by one
        ResultQuery.fetchInto(Class) Fetch records into a custom POJO (optionally annotated with JPA annotations)
        ResultQuery.fetchInto(RecordHandler) Fetch records into a custom callback (similar to Spring's RowMapper)

        Example (Postgres):

         String sql = "FETCH ALL IN \"<unnamed cursor 1>\"";
        Example (SQLite):

         String sql = "pragma table_info('my_table')";

        NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses!

        Parameters:
        sql - The SQL
        Returns:
        An executable query
        See Also:
        SQL
      • resultQuery

        @Support
        @PlainSQL
        ResultQuery<Record> resultQuery​(java.lang.String sql)
        Create a new query holding plain SQL.

        There must not be any bind variables contained in the SQL

        Use this method, when you want to take advantage of the many ways to fetch results in jOOQ, using ResultQuery. Some examples:

        ResultQuery.fetchLazy() Open a cursor and fetch records one by one
        ResultQuery.fetchInto(Class) Fetch records into a custom POJO (optionally annotated with JPA annotations)
        ResultQuery.fetchInto(RecordHandler) Fetch records into a custom callback (similar to Spring's RowMapper)

        Example (Postgres):

         String sql = "FETCH ALL IN \"<unnamed cursor 1>\"";
        Example (SQLite):

         String sql = "pragma table_info('my_table')";

        NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses!

        Parameters:
        sql - The SQL
        Returns:
        An executable query
        See Also:
        SQL
      • resultQuery

        @Support
        @PlainSQL
        ResultQuery<Record> resultQuery​(java.lang.String sql,
                                        java.lang.Object... bindings)
        Create a new query holding plain SQL.

        There must be as many bind variables contained in the SQL, as passed in the bindings parameter

        Use this method, when you want to take advantage of the many ways to fetch results in jOOQ, using ResultQuery. Some examples:

        ResultQuery.fetchLazy() Open a cursor and fetch records one by one
        ResultQuery.fetchInto(Class) Fetch records into a custom POJO (optionally annotated with JPA annotations)
        ResultQuery.fetchInto(RecordHandler) Fetch records into a custom callback (similar to Spring's RowMapper)

        Example (Postgres):

         String sql = "FETCH ALL IN \"<unnamed cursor 1>\"";
        Example (SQLite):

         String sql = "pragma table_info('my_table')";

        NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses!

        Parameters:
        sql - The SQL
        bindings - The bindings
        Returns:
        A query wrapping the plain SQL
        See Also:
        SQL, DSL.sql(String, Object...)
      • resultQuery

        @Support
        @PlainSQL
        ResultQuery<Record> resultQuery​(java.lang.String sql,
                                        QueryPart... parts)
        Create a new query holding plain SQL.

        Unlike resultQuery(String, Object...), the SQL passed to this method should not contain any bind variables. Instead, you can pass QueryPart objects to the method which will be rendered at indexed locations of your SQL string as such:

         // The following query
         resultQuery("select {0}, {1} from {2}", val(1), inline("test"), name("DUAL"));
        
         // Will render this SQL by default, using SQLDialect.ORACLE:
         select ?, 'test' from "DUAL"
         

        NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses! One way to escape literals is to use DSL.name(String...) and similar methods

        Parameters:
        sql - The SQL clause, containing {numbered placeholders} where query parts can be injected
        parts - The QueryPart objects that are rendered at the {numbered placeholder} locations
        Returns:
        A query wrapping the plain SQL
        See Also:
        SQL, DSL.sql(String, QueryPart...)
      • fetch

        @Support
        Result<Record> fetch​(java.sql.ResultSet rs)
                      throws DataAccessException
        Fetch all data from a JDBC ResultSet and transform it to a jOOQ Result.

        After fetching all data, the JDBC ResultSet will be closed.

        Use fetchLazy(ResultSet), to fetch one Record at a time, instead of load the entire ResultSet into a jOOQ Result at once.

        Parameters:
        rs - The JDBC ResultSet to fetch data from
        Returns:
        The resulting jOOQ Result. This will never be null.
        Throws:
        DataAccessException - if something went wrong executing the query
      • fetch

        @Support
        Result<Record> fetch​(java.sql.ResultSet rs,
                             Field<?>... fields)
                      throws DataAccessException
        Fetch all data from a JDBC ResultSet and transform it to a jOOQ Result.

        After fetching all data, the JDBC ResultSet will be closed.

        Use fetchLazy(ResultSet), to fetch one Record at a time, instead of load the entire ResultSet into a jOOQ Result at once.

        The additional fields argument is used by jOOQ to coerce field names and data types to the desired output

        Parameters:
        rs - The JDBC ResultSet to fetch data from
        fields - The fields to use in the desired output
        Returns:
        The resulting jOOQ Result. This will never be null.
        Throws:
        DataAccessException - if something went wrong executing the query
      • fetch

        @Support
        Result<Record> fetch​(java.sql.ResultSet rs,
                             DataType<?>... types)
                      throws DataAccessException
        Fetch all data from a JDBC ResultSet and transform it to a jOOQ Result.

        After fetching all data, the JDBC ResultSet will be closed.

        Use fetchLazy(ResultSet), to fetch one Record at a time, instead of load the entire ResultSet into a jOOQ Result at once.

        The additional types argument is used by jOOQ to coerce data types to the desired output

        Parameters:
        rs - The JDBC ResultSet to fetch data from
        types - The data types to use in the desired output
        Returns:
        The resulting jOOQ Result. This will never be null.
        Throws:
        DataAccessException - if something went wrong executing the query
      • fetch

        @Support
        Result<Record> fetch​(java.sql.ResultSet rs,
                             java.lang.Class<?>... types)
                      throws DataAccessException
        Fetch all data from a JDBC ResultSet and transform it to a jOOQ Result.

        After fetching all data, the JDBC ResultSet will be closed.

        Use fetchLazy(ResultSet), to fetch one Record at a time, instead of load the entire ResultSet into a jOOQ Result at once.

        The additional types argument is used by jOOQ to coerce data types to the desired output

        Parameters:
        rs - The JDBC ResultSet to fetch data from
        types - The data types to use in the desired output
        Returns:
        The resulting jOOQ Result. This will never be null.
        Throws:
        DataAccessException - if something went wrong executing the query
      • fetchOne

        @Support
        Record fetchOne​(java.sql.ResultSet rs)
                 throws DataAccessException,
                        TooManyRowsException
        Fetch a record from a JDBC ResultSet and transform it to a jOOQ Record.

        This will internally fetch all records and throw an exception if there was more than one resulting record.

        Parameters:
        rs - The JDBC ResultSet to fetch data from
        Returns:
        The record or null, if no record was found.
        Throws:
        DataAccessException - if something went wrong executing the query
        TooManyRowsException - if the query returned more than one record
      • fetchOne

        @Support
        Record fetchOne​(java.sql.ResultSet rs,
                        Field<?>... fields)
                 throws DataAccessException,
                        TooManyRowsException
        Fetch a record from a JDBC ResultSet and transform it to a jOOQ Record.

        This will internally fetch all records and throw an exception if there was more than one resulting record.

        The additional fields argument is used by jOOQ to coerce field names and data types to the desired output

        Parameters:
        rs - The JDBC ResultSet to fetch data from
        fields - The fields to use in the desired output
        Returns:
        The record or null, if no record was found.
        Throws:
        DataAccessException - if something went wrong executing the query
        TooManyRowsException - if the query returned more than one record
      • fetchOne

        @Support
        Record fetchOne​(java.sql.ResultSet rs,
                        DataType<?>... types)
                 throws DataAccessException,
                        TooManyRowsException
        Fetch a record from a JDBC ResultSet and transform it to a jOOQ Record.

        This will internally fetch all records and throw an exception if there was more than one resulting record.

        The additional types argument is used by jOOQ to coerce data types to the desired output

        Parameters:
        rs - The JDBC ResultSet to fetch data from
        types - The data types to use in the desired output
        Returns:
        The record or null, if no record was found.
        Throws:
        DataAccessException - if something went wrong executing the query
        TooManyRowsException - if the query returned more than one record
      • fetchOne

        @Support
        Record fetchOne​(java.sql.ResultSet rs,
                        java.lang.Class<?>... types)
                 throws DataAccessException,
                        TooManyRowsException
        Fetch a record from a JDBC ResultSet and transform it to a jOOQ Record.

        This will internally fetch all records and throw an exception if there was more than one resulting record.

        The additional types argument is used by jOOQ to coerce data types to the desired output

        Parameters:
        rs - The JDBC ResultSet to fetch data from
        types - The data types to use in the desired output
        Returns:
        The record. This is never null.
        Throws:
        DataAccessException - if something went wrong executing the query
        TooManyRowsException - if the query returned more than one record
      • fetchSingle

        @Support
        Record fetchSingle​(java.sql.ResultSet rs)
                    throws DataAccessException,
                           TooManyRowsException
        Fetch a record from a JDBC ResultSet and transform it to a jOOQ Record.

        This will internally fetch all records and throw an exception if there was more than one resulting record.

        Parameters:
        rs - The JDBC ResultSet to fetch data from
        Returns:
        The record or null, if no record was found.
        Throws:
        DataAccessException - if something went wrong executing the query
        TooManyRowsException - if the query returned more than one record
      • fetchSingle

        @Support
        Record fetchSingle​(java.sql.ResultSet rs,
                           Field<?>... fields)
                    throws DataAccessException,
                           NoDataFoundException,
                           TooManyRowsException
        Fetch a record from a JDBC ResultSet and transform it to a jOOQ Record.

        This will internally fetch all records and throw an exception if there was more than one resulting record.

        The additional fields argument is used by jOOQ to coerce field names and data types to the desired output

        Parameters:
        rs - The JDBC ResultSet to fetch data from
        fields - The fields to use in the desired output
        Returns:
        The record. This is never null.
        Throws:
        DataAccessException - if something went wrong executing the query
        NoDataFoundException - if the query returned no rows
        TooManyRowsException - if the query returned more than one record
      • fetchSingle

        @Support
        Record fetchSingle​(java.sql.ResultSet rs,
                           DataType<?>... types)
                    throws DataAccessException,
                           NoDataFoundException,
                           TooManyRowsException
        Fetch a record from a JDBC ResultSet and transform it to a jOOQ Record.

        This will internally fetch all records and throw an exception if there was more than one resulting record.

        The additional types argument is used by jOOQ to coerce data types to the desired output

        Parameters:
        rs - The JDBC ResultSet to fetch data from
        types - The data types to use in the desired output
        Returns:
        The record. This is never null.
        Throws:
        DataAccessException - if something went wrong executing the query
        NoDataFoundException - if the query returned no rows
        TooManyRowsException - if the query returned more than one record
      • fetchSingle

        @Support
        Record fetchSingle​(java.sql.ResultSet rs,
                           java.lang.Class<?>... types)
                    throws DataAccessException,
                           NoDataFoundException,
                           TooManyRowsException
        Fetch a record from a JDBC ResultSet and transform it to a jOOQ Record.

        This will internally fetch all records and throw an exception if there was more than one resulting record.

        The additional types argument is used by jOOQ to coerce data types to the desired output

        Parameters:
        rs - The JDBC ResultSet to fetch data from
        types - The data types to use in the desired output
        Returns:
        The record. This is never null.
        Throws:
        DataAccessException - if something went wrong executing the query
        NoDataFoundException - if the query returned no rows
        TooManyRowsException - if the query returned more than one record
      • fetchOptional

        @Support
        java.util.Optional<Record> fetchOptional​(java.sql.ResultSet rs,
                                                 Field<?>... fields)
                                          throws DataAccessException,
                                                 TooManyRowsException
        Fetch a record from a JDBC ResultSet and transform it to a jOOQ Record.

        This will internally fetch all records and throw an exception if there was more than one resulting record.

        The additional fields argument is used by jOOQ to coerce field names and data types to the desired output

        Parameters:
        rs - The JDBC ResultSet to fetch data from
        fields - The fields to use in the desired output
        Returns:
        The resulting jOOQ record
        Throws:
        DataAccessException - if something went wrong executing the query
        TooManyRowsException - if the query returned more than one record
      • fetchOptional

        @Support
        java.util.Optional<Record> fetchOptional​(java.sql.ResultSet rs,
                                                 DataType<?>... types)
                                          throws DataAccessException,
                                                 TooManyRowsException
        Fetch a record from a JDBC ResultSet and transform it to a jOOQ Record.

        This will internally fetch all records and throw an exception if there was more than one resulting record.

        The additional types argument is used by jOOQ to coerce data types to the desired output

        Parameters:
        rs - The JDBC ResultSet to fetch data from
        types - The data types to use in the desired output
        Returns:
        The resulting jOOQ record
        Throws:
        DataAccessException - if something went wrong executing the query
        TooManyRowsException - if the query returned more than one record
      • fetchOptional

        @Support
        java.util.Optional<Record> fetchOptional​(java.sql.ResultSet rs,
                                                 java.lang.Class<?>... types)
                                          throws DataAccessException,
                                                 TooManyRowsException
        Fetch a record from a JDBC ResultSet and transform it to a jOOQ Record.

        This will internally fetch all records and throw an exception if there was more than one resulting record.

        The additional types argument is used by jOOQ to coerce data types to the desired output

        Parameters:
        rs - The JDBC ResultSet to fetch data from
        types - The data types to use in the desired output
        Returns:
        The resulting jOOQ record
        Throws:
        DataAccessException - if something went wrong executing the query
        TooManyRowsException - if the query returned more than one record
      • fetchValue

        @Support
        java.lang.Object fetchValue​(java.sql.ResultSet rs)
                             throws DataAccessException,
                                    TooManyRowsException,
                                    InvalidResultException
        Fetch a record from a JDBC ResultSet and return the only contained value.

        This will internally fetch all records and throw an exception if there was more than one resulting record.

        Parameters:
        rs - The JDBC ResultSet to fetch data from
        Returns:
        The value or null, if no record was found.
        Throws:
        DataAccessException - if something went wrong executing the query
        TooManyRowsException - if the query returned more than one record
        InvalidResultException - if the query returned a record with more than one value
      • fetchValue

        @Support
        <T> T fetchValue​(java.sql.ResultSet rs,
                         Field<T> field)
                  throws DataAccessException,
                         TooManyRowsException,
                         InvalidResultException
        Fetch a record from a JDBC ResultSet and return the only contained value.

        This will internally fetch all records and throw an exception if there was more than one resulting record.

        The additional field argument is used by jOOQ to coerce field names and data types to the desired output

        Parameters:
        rs - The JDBC ResultSet to fetch data from
        field - The field to use in the desired output
        Returns:
        The value or null, if no record was found.
        Throws:
        DataAccessException - if something went wrong executing the query
        TooManyRowsException - if the query returned more than one record
        InvalidResultException - if the query returned a record with more than one value
      • fetchValue

        @Support
        <T> T fetchValue​(java.sql.ResultSet rs,
                         DataType<T> type)
                  throws DataAccessException,
                         TooManyRowsException,
                         InvalidResultException
        Fetch a record from a JDBC ResultSet and return the only contained value.

        This will internally fetch all records and throw an exception if there was more than one resulting record.

        The additional type argument is used by jOOQ to coerce data types to the desired output

        Parameters:
        rs - The JDBC ResultSet to fetch data from
        type - The data type to use in the desired output
        Returns:
        The value or null, if no record was found.
        Throws:
        DataAccessException - if something went wrong executing the query
        TooManyRowsException - if the query returned more than one record
        InvalidResultException - if the query returned a record with more than one value
      • fetchValue

        @Support
        <T> T fetchValue​(java.sql.ResultSet rs,
                         java.lang.Class<T> type)
                  throws DataAccessException,
                         TooManyRowsException,
                         InvalidResultException
        Fetch a record from a JDBC ResultSet and return the only contained value.

        This will internally fetch all records and throw an exception if there was more than one resulting record.

        The additional type argument is used by jOOQ to coerce data types to the desired output

        Parameters:
        rs - The JDBC ResultSet to fetch data from
        type - The data types to use in the desired output
        Returns:
        The value or null, if no record was found.
        Throws:
        DataAccessException - if something went wrong executing the query
        TooManyRowsException - if the query returned more than one record
        InvalidResultException - if the query returned a record with more than one value
      • fetchOptionalValue

        @Support
        java.util.Optional<?> fetchOptionalValue​(java.sql.ResultSet rs)
                                          throws DataAccessException,
                                                 TooManyRowsException,
                                                 InvalidResultException
        Fetch a record from a JDBC ResultSet and return the only contained value.

        This will internally fetch all records and throw an exception if there was more than one resulting record.

        Parameters:
        rs - The JDBC ResultSet to fetch data from
        Returns:
        The resulting value
        Throws:
        DataAccessException - if something went wrong executing the query
        TooManyRowsException - if the query returned more than one record
        InvalidResultException - if the query returned a record with more than one value
      • fetchOptionalValue

        @Support
        <T> java.util.Optional<T> fetchOptionalValue​(java.sql.ResultSet rs,
                                                     Field<T> field)
                                              throws DataAccessException,
                                                     TooManyRowsException,
                                                     InvalidResultException
        Fetch a record from a JDBC ResultSet and return the only contained value.

        This will internally fetch all records and throw an exception if there was more than one resulting record.

        The additional field argument is used by jOOQ to coerce field names and data types to the desired output

        Parameters:
        rs - The JDBC ResultSet to fetch data from
        field - The field to use in the desired output
        Returns:
        The resulting value
        Throws:
        DataAccessException - if something went wrong executing the query
        TooManyRowsException - if the query returned more than one record
        InvalidResultException - if the query returned a record with more than one value
      • fetchOptionalValue

        @Support
        <T> java.util.Optional<T> fetchOptionalValue​(java.sql.ResultSet rs,
                                                     DataType<T> type)
                                              throws DataAccessException,
                                                     TooManyRowsException,
                                                     InvalidResultException
        Fetch a record from a JDBC ResultSet and return the only contained value.

        This will internally fetch all records and throw an exception if there was more than one resulting record.

        The additional type argument is used by jOOQ to coerce data types to the desired output

        Parameters:
        rs - The JDBC ResultSet to fetch data from
        type - The data type to use in the desired output
        Returns:
        The resulting value
        Throws:
        DataAccessException - if something went wrong executing the query
        TooManyRowsException - if the query returned more than one record
        InvalidResultException - if the query returned a record with more than one value
      • fetchOptionalValue

        @Support
        <T> java.util.Optional<T> fetchOptionalValue​(java.sql.ResultSet rs,
                                                     java.lang.Class<T> type)
                                              throws DataAccessException,
                                                     TooManyRowsException,
                                                     InvalidResultException
        Fetch a record from a JDBC ResultSet and return the only contained value.

        This will internally fetch all records and throw an exception if there was more than one resulting record.

        The additional type argument is used by jOOQ to coerce data types to the desired output

        Parameters:
        rs - The JDBC ResultSet to fetch data from
        type - The data types to use in the desired output
        Returns:
        The resulting value
        Throws:
        DataAccessException - if something went wrong executing the query
        TooManyRowsException - if the query returned more than one record
        InvalidResultException - if the query returned a record with more than one value
      • fetchValues

        @Support
        java.util.List<?> fetchValues​(java.sql.ResultSet rs)
                               throws DataAccessException,
                                      InvalidResultException
        Fetch a result from a JDBC ResultSet and return the only contained column's values.
        Parameters:
        rs - The JDBC ResultSet to fetch data from
        Returns:
        The values. This will never be null.
        Throws:
        DataAccessException - if something went wrong executing the query
        InvalidResultException - if the query returned a record with more than one value
      • fetchValues

        @Support
        <T> java.util.List<T> fetchValues​(java.sql.ResultSet rs,
                                          Field<T> field)
                                   throws DataAccessException,
                                          InvalidResultException
        Fetch a result from a JDBC ResultSet and return the only contained column's values.

        The additional field argument is used by jOOQ to coerce field names and data types to the desired output

        Parameters:
        rs - The JDBC ResultSet to fetch data from
        field - The field to use in the desired output
        Returns:
        The values. This will never be null.
        Throws:
        DataAccessException - if something went wrong executing the query
        InvalidResultException - if the query returned a record with more than one value
      • fetchValues

        @Support
        <T> java.util.List<T> fetchValues​(java.sql.ResultSet rs,
                                          DataType<T> type)
                                   throws DataAccessException,
                                          InvalidResultException
        Fetch a result from a JDBC ResultSet and return the only contained column's values.

        The additional type argument is used by jOOQ to coerce data types to the desired output

        Parameters:
        rs - The JDBC ResultSet to fetch data from
        type - The data type to use in the desired output
        Returns:
        The values. This will never be null.
        Throws:
        DataAccessException - if something went wrong executing the query
        InvalidResultException - if the query returned a record with more than one value
      • fetchValues

        @Support
        <T> java.util.List<T> fetchValues​(java.sql.ResultSet rs,
                                          java.lang.Class<T> type)
                                   throws DataAccessException,
                                          InvalidResultException
        Fetch a result from a JDBC ResultSet and return the only contained column's values.

        The additional type argument is used by jOOQ to coerce data types to the desired output

        Parameters:
        rs - The JDBC ResultSet to fetch data from
        type - The data types to use in the desired output
        Returns:
        The values. This will never be null.
        Throws:
        DataAccessException - if something went wrong executing the query
        InvalidResultException - if the query returned a record with more than one value
      • fetchLazy

        @Support
        Cursor<Record> fetchLazy​(java.sql.ResultSet rs,
                                 Field<?>... fields)
                          throws DataAccessException
        Wrap a JDBC ResultSet into a jOOQ Cursor.

        Use fetch(ResultSet), to load the entire ResultSet into a jOOQ Result at once.

        The additional fields argument is used by jOOQ to coerce field names and data types to the desired output

        Parameters:
        rs - The JDBC ResultSet to fetch data from
        fields - The fields to use in the desired output
        Returns:
        The cursor. This will never be null.
        Throws:
        DataAccessException - if something went wrong executing the query
      • fetchLazy

        @Support
        Cursor<Record> fetchLazy​(java.sql.ResultSet rs,
                                 DataType<?>... types)
                          throws DataAccessException
        Wrap a JDBC ResultSet into a jOOQ Cursor.

        Use fetch(ResultSet), to load the entire ResultSet into a jOOQ Result at once.

        The additional types argument is used by jOOQ to coerce data types to the desired output

        Parameters:
        rs - The JDBC ResultSet to fetch data from
        types - The data types to use in the desired output
        Returns:
        The cursor. This will never be null.
        Throws:
        DataAccessException - if something went wrong executing the query
      • fetchLazy

        @Support
        Cursor<Record> fetchLazy​(java.sql.ResultSet rs,
                                 java.lang.Class<?>... types)
                          throws DataAccessException
        Wrap a JDBC ResultSet into a jOOQ Cursor.

        Use fetch(ResultSet), to load the entire ResultSet into a jOOQ Result at once.

        The additional types argument is used by jOOQ to coerce data types to the desired output

        Parameters:
        rs - The JDBC ResultSet to fetch data from
        types - The data types to use in the desired output
        Returns:
        The cursor. This will never be null.
        Throws:
        DataAccessException - if something went wrong executing the query
      • fetchAsync

        @Support
        java.util.concurrent.CompletionStage<Result<Record>> fetchAsync​(java.sql.ResultSet rs)
        Fetch results in a new CompletionStage.

        The result is asynchronously completed by a task running in an Executor provided by the Scope.configuration()'s Configuration.executorProvider().

        Parameters:
        rs - The JDBC ResultSet to fetch data from
        Returns:
        The completion stage. The completed result will never be null.
      • fetchAsync

        @Support
        java.util.concurrent.CompletionStage<Result<Record>> fetchAsync​(java.sql.ResultSet rs,
                                                                        Field<?>... fields)
        Fetch results in a new CompletionStage.

        The result is asynchronously completed by a task running in an Executor provided by the Scope.configuration()'s Configuration.executorProvider().

        The additional fields argument is used by jOOQ to coerce field names and data types to the desired output

        Parameters:
        rs - The JDBC ResultSet to fetch data from
        fields - The fields to use in the desired output
        Returns:
        The completion stage. The completed result will never be null.
      • fetchAsync

        @Support
        java.util.concurrent.CompletionStage<Result<Record>> fetchAsync​(java.sql.ResultSet rs,
                                                                        DataType<?>... types)
        Fetch results in a new CompletionStage.

        The result is asynchronously completed by a task running in an Executor provided by the Scope.configuration()'s Configuration.executorProvider().

        The additional types argument is used by jOOQ to coerce data types to the desired output

        Parameters:
        rs - The JDBC ResultSet to fetch data from
        types - The data types to use in the desired output
        Returns:
        The completion stage. The completed result will never be null.
      • fetchAsync

        @Support
        java.util.concurrent.CompletionStage<Result<Record>> fetchAsync​(java.sql.ResultSet rs,
                                                                        java.lang.Class<?>... types)
        Fetch results in a new CompletionStage.

        The result is asynchronously completed by a task running in an Executor provided by the Scope.configuration()'s Configuration.executorProvider().

        The additional types argument is used by jOOQ to coerce data types to the desired output

        Parameters:
        rs - The JDBC ResultSet to fetch data from
        types - The data types to use in the desired output
        Returns:
        The completion stage. The completed result will never be null.
      • fetchAsync

        @Support
        java.util.concurrent.CompletionStage<Result<Record>> fetchAsync​(java.util.concurrent.Executor executor,
                                                                        java.sql.ResultSet rs)
        Fetch results in a new CompletionStage that is asynchronously completed by a task running in the given executor.
        Parameters:
        rs - The JDBC ResultSet to fetch data from
        Returns:
        The completion stage. The completed result will never be null.
      • fetchAsync

        @Support
        java.util.concurrent.CompletionStage<Result<Record>> fetchAsync​(java.util.concurrent.Executor executor,
                                                                        java.sql.ResultSet rs,
                                                                        Field<?>... fields)
        Fetch results in a new CompletionStage that is asynchronously completed by a task running in the given executor.

        The additional fields argument is used by jOOQ to coerce field names and data types to the desired output

        Parameters:
        rs - The JDBC ResultSet to fetch data from
        fields - The fields to use in the desired output
        Returns:
        The completion stage. The completed result will never be null.
      • fetchAsync

        @Support
        java.util.concurrent.CompletionStage<Result<Record>> fetchAsync​(java.util.concurrent.Executor executor,
                                                                        java.sql.ResultSet rs,
                                                                        DataType<?>... types)
        Fetch results in a new CompletionStage that is asynchronously completed by a task running in the given executor.

        The additional types argument is used by jOOQ to coerce data types to the desired output

        Parameters:
        rs - The JDBC ResultSet to fetch data from
        types - The data types to use in the desired output
        Returns:
        The completion stage. The completed result will never be null.
      • fetchAsync

        @Support
        java.util.concurrent.CompletionStage<Result<Record>> fetchAsync​(java.util.concurrent.Executor executor,
                                                                        java.sql.ResultSet rs,
                                                                        java.lang.Class<?>... types)
        Fetch results in a new CompletionStage that is asynchronously completed by a task running in the given executor.

        The additional types argument is used by jOOQ to coerce data types to the desired output

        Parameters:
        rs - The JDBC ResultSet to fetch data from
        types - The data types to use in the desired output
        Returns:
        The completion stage. The completed result will never be null.
      • fetchStream

        @Support
        java.util.stream.Stream<Record> fetchStream​(java.sql.ResultSet rs)
                                             throws DataAccessException
        Wrap a JDBC ResultSet into a jOOQ Stream.

        Use fetch(ResultSet), to load the entire ResultSet into a jOOQ Result at once.

        Parameters:
        rs - The JDBC ResultSet to fetch data from
        Returns:
        The resulting stream
        Throws:
        DataAccessException - if something went wrong executing the query
      • fetchStream

        @Support
        java.util.stream.Stream<Record> fetchStream​(java.sql.ResultSet rs,
                                                    Field<?>... fields)
                                             throws DataAccessException
        Wrap a JDBC ResultSet into a jOOQ Stream.

        Use fetch(ResultSet), to load the entire ResultSet into a jOOQ Result at once.

        The additional fields argument is used by jOOQ to coerce field names and data types to the desired output

        Parameters:
        rs - The JDBC ResultSet to fetch data from
        fields - The fields to use in the desired output
        Returns:
        The resulting stream
        Throws:
        DataAccessException - if something went wrong executing the query
      • fetchStream

        @Support
        java.util.stream.Stream<Record> fetchStream​(java.sql.ResultSet rs,
                                                    DataType<?>... types)
                                             throws DataAccessException
        Wrap a JDBC ResultSet into a jOOQ Stream.

        Use fetch(ResultSet), to load the entire ResultSet into a jOOQ Result at once.

        The additional types argument is used by jOOQ to coerce data types to the desired output

        Parameters:
        rs - The JDBC ResultSet to fetch data from
        types - The data types to use in the desired output
        Returns:
        The resulting stream
        Throws:
        DataAccessException - if something went wrong executing the query
      • fetchStream

        @Support
        java.util.stream.Stream<Record> fetchStream​(java.sql.ResultSet rs,
                                                    java.lang.Class<?>... types)
                                             throws DataAccessException
        Wrap a JDBC ResultSet into a jOOQ Stream.

        Use fetch(ResultSet), to load the entire ResultSet into a jOOQ Result at once.

        The additional types argument is used by jOOQ to coerce data types to the desired output

        Parameters:
        rs - The JDBC ResultSet to fetch data from
        types - The data types to use in the desired output
        Returns:
        The resulting stream
        Throws:
        DataAccessException - if something went wrong executing the query
      • fetchFromTXT

        @Support
        Result<Record> fetchFromTXT​(java.lang.String string)
                             throws DataAccessException
        Fetch all data from a formatted string.

        The supplied string is supposed to be formatted in a human-readable way. This is the same as calling fetchFromTXT(string, "{null}")

        Parameters:
        string - The formatted string
        Returns:
        The transformed result. This will never be null.
        Throws:
        DataAccessException - If the supplied string does not adhere to the above format rules.
        See Also:
        fetchFromTXT(String, String)
      • fetchFromTXT

        @Support
        Result<Record> fetchFromTXT​(java.lang.String string,
                                    java.lang.String nullLiteral)
                             throws DataAccessException
        Fetch all data from a formatted string.

        This method supports parsing results from two types of human-readable formats:

        The jOOQ Formattable.format()

        This format is recognised by the fact that the first line starts with a "plus" sign:

         +-----+-----+--------------------------+
         |COL1 |COL2 |COL3 containing whitespace|
         +-----+-----+--------------------------+
         |val1 |1    |some text                 |
         |val2 | 2   | more text                |
         +-----+-----+--------------------------+
         
        This method will decode the above formatted string according to the following rules:
        • The number of columns is defined by the number of dash groups in the first line. Groups are separated by exactly one "plus" sign
        • The column types are VARCHAR(N) where N = number of dashes per dash group
        • The column names are defined by the trimmed text contained in the second row
        • The data is defined by the trimmed text contained in the subsequent rows

        The H2 database test data format

        The supplied string is supposed to be formatted in the following, human-readable way:

         COL1  COL2   COL3 containing whitespace
         ----- ----   --------------------------
         val1  1      some text
         val2   2      more text
         
        This method will decode the above formatted string according to the following rules:
        • The number of columns is defined by the number of dash groups in the second line. Groups are separated by space(s)
        • The column types are VARCHAR(N) where N = number of dashes per dash group
        • The column names are defined by the trimmed text contained in the first row
        • The data is defined by the trimmed text contained in the subsequent rows

        Both parsing methods

        Both parsing methods make no assumption about the resulting data types. Instead, all data is string-based.

        Parameters:
        string - The formatted string
        nullLiteral - The string literal to be used as null value.
        Returns:
        The transformed result. This will never be null.
        Throws:
        DataAccessException - If the supplied string does not adhere to the above format rules.
      • fetchFromHTML

        @Support
        Result<Record> fetchFromHTML​(java.lang.String string)
                              throws DataAccessException
        Convert an HTML table into a jOOQ Result.

        This is the inverse operation of Formattable.formatHTML(). It works according to the following parsing rules:

        • The input is expected to be well-formed XML. XHTML conformance is not required - i.e. unknown elements / attributes, or elements / attributes not specified here, such as <caption>, <thead>, <tbody> are simply ignored.
        • The surrounding <table> element is optional, but it may appear only once
        • A single row containing table headings <th> is allowed. Further rows containing table headings are ignored. Table headings define field names. In the absence of table headings, field names are generated.
        • The first row <tr> specifies the number of columns in the table (regardless if it contains table headings or not). Subsequent rows containing less columns will be padded. Subsequent rows containing more columns will be truncated.
        • Comments are ignored
        • Nested tables are not supported

        Ideal input looks like this:

         <table>
         <tr><th>COL1</th><th>COL2</th></tr>
         <tr><td>1</td><td>a</td></tr>
         <tr><td>2</td><td>b</td></tr>
         </table>
         
         
        Parameters:
        string - The HTML-formatted string.
        Returns:
        The transformed result. This will never be null.
        Throws:
        DataAccessException - If the supplied string does not adhere to the above format rules.
      • fetchFromStringData

        Result<Record> fetchFromStringData​(java.lang.String[]... data)
        Fetch all data from a list of strings.

        This is used by methods such as

        The first element of the argument list should contain column names. Subsequent elements contain actual data. The degree of all arrays contained in the argument should be the same, although this is not a requirement. jOOQ will ignore excess data, and fill missing data with null.
        Parameters:
        data - The data to be transformed into a Result
        Returns:
        The transformed result. This will never be null.
        See Also:
        fetchFromStringData(List)
      • fetchFromStringData

        Result<Record> fetchFromStringData​(java.util.List<java.lang.String[]> data)
        Fetch all data from a list of strings.

        This is used by methods such as

        The first element of the argument list should contain column names. Subsequent elements contain actual data. The degree of all arrays contained in the argument should be the same, although this is not a requirement. jOOQ will ignore excess data, and fill missing data with null.
        Parameters:
        data - The data to be transformed into a Result
        Returns:
        The transformed result. This will never be null.
      • fetchFromStringData

        Result<Record> fetchFromStringData​(java.util.List<java.lang.String[]> data,
                                           boolean header)
        Fetch all data from a list of strings.

        This is used by methods such as