• 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

Using Datasource with and without transaction

 
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In a servlet, I have two methods that executes two different sql statements.
So from doPost, I use datasource.getConnection(), call first method, close the connection; again use datasource.getConnection(), call second method, close connection.
Now, how are these connections handled by pool when I wrap these method calls with usertransaction(s), and when donot use usertransaction at all?
I mean will these be two different physical/logical connections, and does it vary with/without usage of transactions?
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not sure what the answer to your question is but why are you using two connections in one method call?
 
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You will get a new connection from the pool and as far the transaction is concerned both the transactions would behave independently.
 
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

You will get a new connection from the pool and as far the transaction is concerned both the transactions would behave independently.



Is this new connection a logical/physical connection? Does it vary with and without usage of user transactions?

And when I donot use usertransaction.begin() and commit/rollback(), how are the transactions managed between these two methods?
 
reply
    Bookmark Topic Watch Topic
  • New Topic