Thanks. So it helps if I read the Javadoc :). I thought I read it all, but that little call slipped in there unchecked :).

Thanks, Ryan




On 3/12/2012 8:45 PM, Lukas Eder wrote:
I'm using a Connection Pool and providing it to the JOOQ Factory. So it
should open and close connections automatically?
I really have to address this issue in jOOQ 3.0 :-)

The problem is I have a connection leak. If I comment out the
factory.setAutoCommit(true) then I don't get the connection leak, but I'd
like auto commit on so any updates are automatically committed.
Here's the problem:
http://www.jooq.org/javadoc/latest/org/jooq/impl/Factory.html#setAutoCommit(boolean)

It reads:
--------
Use this method only if you control the JDBC Connection wrapped by
this Configuration, and if that connection manages the current
transaction. If your transaction is operated on a distributed
javax.transaction.UserTransaction, for instance, this method will not
work.

So. Am I using this in the wrong way?. I guess the setAutoCommit shouldn't
really be called until the .execute() or .fetch() when JOOQ gets the
connection?
Yes, you're using it in the "wrong" way, as the "correct" way has been
confusing many users on this list. jOOQ's DataSource support was
designed to support container-managed, pooled DataSources potentially
using distributed transactions.

In other words, if you pass a DataSource to jOOQ, jOOQ will get/close
connections for you, i.e. "you don't control the JDBC connection
wrapped by this Configuration".

The best solution for you right now is to configure your data source /
connection pool to provide jOOQ with connections that have the
auto-commit flag set to true. I.e. you should set the auto commit flag
inside DataSource.getConnection(), not on the Factory

Cheers
Lukas


Reply via email to