 |
AppletTalk.com Java discussions newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Gaurav Guest
|
Posted: Sat Sep 13, 2003 9:05 am Post subject: Pending Transactions in a connection |
|
|
Hi,
When we return a connection to the pool. We want to check if it has some
un-commited transactions. JDBC provides a method to check if the
connection autoCOmmit mode is true or false but how can we know the
number of pending statements within it.
Thanks in advance.
Gaurav
|
|
| Back to top |
|
 |
Joseph Weinstein Guest
|
Posted: Sat Sep 13, 2003 10:27 pm Post subject: Re: Pending Transactions in a connection |
|
|
Gaurav wrote:
| Quote: | Hi,
When we return a connection to the pool. We want to check if it has some
un-commited transactions. JDBC provides a method to check if the
connection autoCOmmit mode is true or false but how can we know the
number of pending statements within it.
Thanks in advance.
Gaurav
|
I am not sure what you mean by 'pending statements'. Do you mean jdbc Statement
objects, or SQL updates, such as insert, update and delete statements? In any case,
if the connection you find is in autoCommit(false) mode the connection may have 0
or more updates pending, and/or may be holding 0 or more read-locks depending on
the DBMS and isolation level. The only thing you could do with standard JDBC would
be to run a query specific to the DBMS's system tables, which might reveal what
locks this connection holds, but that wouldn't reveal the actual update SQL statements.
You have a responsibility to the system throughput and DBMS. In my opinion, you
cannot take the responsibility to commit an unknown, partial, abandoned transaction.
You should just roll back the connection and reset it to autoCommit(true) mode so the
next user gets a connection in standard condition. It is the responsibility of the application
code that uses a pool connection to be rational with it's transactions. If it is, then the
application will have done it's commit, and there will be nothing pending. In such a
case you would be able to reset the isolation level to the default level, and would be
able to set autoCommit(true) without doing a rollback first. If the user had left a partial
transaction then those two calls would probably get an exception, and you would then
have to do a rollback before resetting those.
Joe Weinstein.
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|