• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Difference between connection.commit and usertransaction.commit

 
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author
Posts: 4335
39
jQuery Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic