> Is there any way to construct the query with jooq without first having
> the connection? That is, instead of building the DSL from the Factory
> (which can only be constructed from a Connection so far as I can
> tell), use the same DSL with needing the connection and not provide
> the connection until the query execution / fetch / etc.?

The connection is only needed at execute time, not at render time. So
you can safely pass null as a connection if you don't need it at
construct time.

You can always set the connection on the factory later:
http://www.jooq.org/javadoc/latest/org/jooq/impl/Factory.html#setConnection(java.sql.Connection)

Note, jOOQ 2.3.0 will also ship with connection-less constructors:
https://sourceforge.net/apps/trac/jooq/ticket/1303

> My reason for wanting to do so has to do with constructing a utility
> class to encapsulate all the boilerplate of creating and cleaning up
> the connection and exception handling, into one place across many jooq
> operations, which is made more awkward by needing the connection
> before you can construct the query. If you want, I can provide the
> long-winded details and show you the code.

Yes, why not. It might be interesting for the record.

Cheers
Lukas

Reply via email to