public Result<Record> executeStatementWithResult( DSLContext dsl, String statement, Context context, SetupPreparedStatement statementSetup) { Connection c = dsl.configuration().connectionProvider().acquire(); try (PreparedStatement ps = c.prepareStatement(statement)) { statementSetup.accept(ps); try (ResultSet resultSet = ps.executeQuery()) { return dsl.fetch(resultSet); } } catch (SQLException ex) { throw errorHandler.handleException(context, ex); } finally { dsl.configuration().connectionProvider().release(c); } }