Re: Autocommit, Implicit Transactions, and Connection Pools
- From: Joe Weinstein <joeNOSPAM@xxxxxxx>
- Date: Thu, 06 Mar 2008 15:37:40 -0800
Joe Weinstein wrote:
Wes Clark wrote:
I agree that running queries in autocommit mode with doing a commit could lead to unwanted locks. We do extensive performance testing, and haven't run into any problem, though.
My question is what is the difference between setting autocommit on using the method on the connection object, and running a command on the server to turn on implicit connections.
Hi. Maybe nothing. The driver may implement the setAutoCommit(false)
mode by sending the T-SQL to set implicit trasnsactions on.
Does the connection object keep any internal state that would then be out of sync with the server?
Yes it may well. The driver may keep a flag denoting it's autocommit state,
and sending the SQL yourself may be asking to confuse the driver. You can
test it may seeing what getAutoCommit() returns after you send the "set implcit..."
via a statement. That driver flag may or may not be important though. Test whether
a commit or rollback still works after you've snuck around the driver with the
SQL instead of the setAutoCommit() call.
I checked. You should definitely stick to all JDBC calls to do this
work. If you try to do it via SQL, the driver will still think autoCommit
is true, so commit() and rollback() will do nothing.
Joe
I know I can set transaction isolation level also with a command to SQL Server, as well as a method on the connection object, so the same question applies. I guess I'd like to hear from the Microsoft developers.
In the case of the isolation level, it is a purely DBMS internal behavior,
so no driver behavior would change, except getTransactionIsolation() might
be tricked into returning the default value if setTransactionIsolation()
hadn't been called.
Connection.setReadOnly() is documented as "Puts this connection in read-only mode as a hint to the driver to enable database optimizations." So this is not a setting on the server at all.
I can tell you that the MS driver does absolutely nothing with that call
except to throw an exception if the connection is already closed.
.
- References:
- Re: Autocommit, Implicit Transactions, and Connection Pools
- From: Joe Weinstein
- Re: Autocommit, Implicit Transactions, and Connection Pools
- From: Joe Weinstein
- Re: Autocommit, Implicit Transactions, and Connection Pools
- Prev by Date: Re: Autocommit, Implicit Transactions, and Connection Pools
- Next by Date: How to configure a .cfg file for sqljdbc.jar
- Previous by thread: Re: Autocommit, Implicit Transactions, and Connection Pools
- Next by thread: Re: Autocommit, Implicit Transactions, and Connection Pools
- Index(es):
Relevant Pages
|
Loading