 |
|
 |
|
Next: New JDBC 1.2 driver runs slower than JDBC 1.1 dri..
|
| Author |
Message |
External

Since: Mar 06, 2008 Posts: 13
|
(Msg. 1) Posted: Thu Mar 06, 2008 11:18 am
Post subject: Autocommit, Implicit Transactions, and Connection Pools Archived from groups: microsoft>public>sqlserver>jdbcdriver (more info?)
|
|
|
Our ISV application can manage its own connection pool, using a modified
version of the Apache Commons DBCP. Customers would like the option of using
the WebSphere or WebLogic provided DataSource ConnectionPools.
When we manage our the connection pool ourselves, we set three properties on
the connection when we first get the connection and before we put it in the
pool: autocommit to false, readonly to false, and transactionisolation to
readCommitted.
WebSphere and WebLogic connection pools gets the connection from the
DataSource, and there doesn't appear to be any options in either product to
specify these connection properties. That means we need to issue these set
properties method calls on the connection each time we borrow one from the
external pool
My question is what is the implementation in the MS JDBC driver? Do any of
these Connection method calls result in database round trips? Or does the
driver handle these properties in how the transactions, etc., are being
managed? Is the driver smart enough to know if the properties are being
changed, that is, are being set to a different value, or to the value which
was previously set? >> Stay informed about: Autocommit, Implicit Transactions, and Connection Pools |
|
| Back to top |
|
 |  |
External

Since: Oct 24, 2003 Posts: 232
|
(Msg. 2) Posted: Thu Mar 06, 2008 11:39 am
Post subject: Re: Autocommit, Implicit Transactions, and Connection Pools [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
Wes Clark wrote:
> Our ISV application can manage its own connection pool, using a modified
> version of the Apache Commons DBCP. Customers would like the option of using
> the WebSphere or WebLogic provided DataSource ConnectionPools.
>
> When we manage our the connection pool ourselves, we set three properties on
> the connection when we first get the connection and before we put it in the
> pool: autocommit to false, readonly to false, and transactionisolation to
> readCommitted.
>
> WebSphere and WebLogic connection pools gets the connection from the
> DataSource, and there doesn't appear to be any options in either product to
> specify these connection properties. That means we need to issue these set
> properties method calls on the connection each time we borrow one from the
> external pool
>
> My question is what is the implementation in the MS JDBC driver? Do any of
> these Connection method calls result in database round trips? Or does the
> driver handle these properties in how the transactions, etc., are being
> managed? Is the driver smart enough to know if the properties are being
> changed, that is, are being set to a different value, or to the value which
> was previously set?
Hi Wes. In WebLogic you might be able to do what you want via the overloaded
'TestTable' parameter for the pool. You can specifiy any SQL to be sent to
the DBMS whenver the connection is reserved by setting the 'test table' to
"SQL set read-only false" (if that's the syntax SQLServer wants) etc.
Note though that any JDBC connection to SQLServer will be read-only false
and isolation level read-committed by default so you don't need to do those.
If you only want you change(s) done once, you can do it via the WebLogic initSQL
parameter. In either case, yo could make a stored procedure to do a long list
of stuff, and then call it via test table = "exec my_proc".
Lastly, I worry about your wanting autoCommit(false) as a default. Note that
anything the connection does to test the connection would start a transaction
and might lock data it reads until the connection gets a commit. Your application
would have to do a commit every time it uses a connection, and I hope it never
locks something someone else wants to update.
Joe Weinstein at BEA Systems >> Stay informed about: Autocommit, Implicit Transactions, and Connection Pools |
|
| Back to top |
|
 |  |
External

Since: Mar 06, 2008 Posts: 13
|
(Msg. 3) Posted: Thu Mar 06, 2008 2:46 pm
Post subject: Re: Autocommit, Implicit Transactions, and Connection Pools [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
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. Does the connection object keep any internal
state that would then be out of sync with the server? 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.
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. >> Stay informed about: Autocommit, Implicit Transactions, and Connection Pools |
|
| Back to top |
|
 |  |
External

Since: Oct 24, 2003 Posts: 232
|
(Msg. 4) Posted: Thu Mar 06, 2008 3:01 pm
Post subject: Re: Autocommit, Implicit Transactions, and Connection Pools [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
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 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. >> Stay informed about: Autocommit, Implicit Transactions, and Connection Pools |
|
| Back to top |
|
 |  |
External

Since: Oct 24, 2003 Posts: 232
|
(Msg. 5) Posted: Thu Mar 06, 2008 3:37 pm
Post subject: Re: Autocommit, Implicit Transactions, and Connection Pools [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
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.
> >> Stay informed about: Autocommit, Implicit Transactions, and Connection Pools |
|
| Back to top |
|
 |  |
External

Since: Mar 06, 2008 Posts: 13
|
(Msg. 6) Posted: Fri Mar 07, 2008 8:58 am
Post subject: Re: Autocommit, Implicit Transactions, and Connection Pools [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
|
|
| Back to top |
|
 |  |
External

Since: Nov 21, 2006 Posts: 24
|
(Msg. 7) Posted: Sun Mar 16, 2008 7:46 pm
Post subject: Re: Autocommit, Implicit Transactions, and Connection Pools [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
Wes,
Based on the conversation between yourself and Joe, we have decided to go back and rethink this portion of our documention. No promises, but we will at
least give it some serious thought.
Evan
--------------------
>Thread-Topic: Autocommit, Implicit Transactions, and Connection Pools
>thread-index: AciAdGinvj3A+I0CQvC0F+hHOxmpMw==
>X-WBNR-Posting-Host: 69.108.213.131
>From: =?Utf-8?B?V2VzIENsYXJr?=
>References: <F90058C3-4B68-406B-
9B58-2D41D3842838.DeleteThis@microsoft.com>
>Subject: Re: Autocommit, Implicit Transactions, and Connection Pools
>Date: Fri, 7 Mar 2008 08:58:04 -0800
>Lines: 4
>Message-ID:
>MIME-Version: 1.0
>Content-Type: text/plain;
> charset="Utf-8"
>Content-Transfer-Encoding: 7bit
>X-Newsreader: Microsoft CDO for Windows 2000
>Content-Class: urn:content-classes:message
>Importance: normal
>Priority: normal
>X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.2992
>Newsgroups: microsoft.public.sqlserver.jdbcdriver
>Path: TK2MSFTNGHUB02.phx.gbl
>Xref: TK2MSFTNGHUB02.phx.gbl microsoft.public.sqlserver.jdbcdriver:459
>NNTP-Posting-Host: tk2msftibfm01.phx.gbl 10.40.244.149
>X-Tomcat-NG: microsoft.public.sqlserver.jdbcdriver
>
>Thanks, Joe.
>
>I wonder if the MS JDBC driver documentation should be updated for these
>methods on the Connection class to provide this advice. I looked there first.
>
Evan T. Basalik
This posting is provided “AS IS” with no warranties, and confers no rights. >> Stay informed about: Autocommit, Implicit Transactions, and Connection Pools |
|
| Back to top |
|
 |  |
| Related Topics: | JDBC driver doesn't close socket event after connection.cl.. - Hi I have a Java application (on Red Hat Enterprise) that <font color=purple> ; 1) connects every 10 seconds to an MS/SQL database</font> <font color=purple> ; 2) attempts to get the metadata for a specific table</fo...
MDX and JDBC Driver - Hi all, Anybody know if it possible to connect to an as2000 database and run mdx queries using the microsoft jdbc drivers? thanks, Peter
java.sql.SQLException: [Microsoft][SQLServer JDBC Driver]U.. - Folks, I was getting this exception occasionally and tracked in down to the application server C drive being full. Looks like the drivers are writing to logs (event ?) on this drive. Freeing up space removed the problem. Hope this helps someone. ..
Redistribution -
I can not connect to SQL Server 2000 on WinXP SP2 - Hi, I am using 'SQLServer 2000 Driver for JDBC' in my java application. My SQL Server is running in Windows XP pc. I dont had any problem before install WindowsXP Service Pack 2. But when i have installed WinXP SP2 my application can not connected to.. |
|
You can post new topics in this forum You can reply to topics in this forum You can edit your posts in this forum You can delete your posts in this forum You can vote in polls in this forum
|
|
|
|
 |
|
|