title: Mix JOOQ query with JDBC transaction
body: <p>I have a use case where I would like to mix a jdbc transaction with jooq context.</p>
  <p>The JDBC code looks like that:</p>
  <pre><code>  public void inTransaction(InTransaction lambda) {
      DataSource ds = dataSource.get();
      try (Connection connection = ds.getConnection()) {
        try {
          logger.info(&quot;set autocommit to false&quot;);
          connection.setAutoCommit(false);
          try (Statement statement = connection.createStatement()) {
            lambda.execute(statement);
            logger.info(&quot;commiting transaction&quot;);
            connection.commit();
          }
        } catch (RuntimeException e) {
          logger.info(&quot;rolling back transaction&quot;);
          connection.rollback();
          throw e;
        } finally {
          logger.info(&quot;set autocommit to true&quot;);
          connection.setAutoCommit(true);
        }
      } catch (SQLException e) {
        throw new TilerException(e);
      }
    }
  
    @FunctionalInterface
    public interface InTransaction {
      void execute(Statement statement) throws SQLException;
    }
  </code></pre>
  <p>And I would like the <code>lambda</code> parameter to be able to work with both jdbc and jooq.</p>
  <p>For jdbc using a statement is pretty straight-forward. For example something like this <a href="https://www.tutorialspoint.com/jdbc/jdbc-transactions.htm" rel="nofollow noreferrer">tutorail</a>:</p>
  <pre><code> inTransaction(stmt -&gt; {
     String SQL = &quot;INSERT INTO Employees  &quot; +
                  &quot;VALUES (106, 20, 'Rita', 'Tez')&quot;;
     stmt.executeUpdate(SQL);
     String SQL = &quot;INSERTED IN Employees  &quot; +
                  &quot;VALUES (107, 22, 'Sita', 'Singh')&quot;;
     stmt.executeUpdate(SQL);
   });
  </code></pre>
  <p>In order to execute jooq queries on the same transaction I have to obtain a context. I found an <a href="https://www.jooq.org/doc/3.1/manual/sql-building/dsl-context/" rel="nofollow noreferrer">api</a> to get a DSLContext from datasource/connection.<br />
  What is not clear to me is if/how to create a jooq <code>DSLContext</code> from a statement?</p>