Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Difference between connection.commit and usertransaction.commit

 
Babji Reddy
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
If I get a connection from a datasource (conn pool) then what is the difference between
(1)commit()/rollback() on the connection direction
Versus
(2) commit() /rollback() on the user transaction
Thanks
 
Scott Selikoff
author
Saloon Keeper
Posts: 4015
18
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One's a database operation, the other a user process.
 
Babji Reddy
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
connect.commit() is database process and usertxn.commit() is user process right? But what does this mean to the developer or to the runtime?
Given that there are two choices of doing things, which one should I pick and why?
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34672
367
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Babji,
They mean different things. Suppose a transaction contains multiple database connections. Committing the user transaction would commit all of them. Whereas committing the connection would only commit one.
 
Babji Reddy
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Jeanne,
If a transaction contains multiple database connections, then its a distributed /XA transaction right?
Lets keep it as multiple i/o operations with the same database. which can be commit/rollback either using a single usertransaction or connection.

When we use UserTransaction the transaction manager/service uses a default timeout (which if we want, we can overwrite using setTransactionTimeout method)
But if I use a connection directly (for a set of lengthy database processes) then I donot need to worry about the timeout. is this right?
If so is this the only difference?
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34672
367
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Babji,
Connections have inactivity timeouts. I don't recall whether they have timeouts if the connection is in use the whole time.
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic