• Post Reply Bookmark Topic Watch Topic
  • New Topic

Using Datasource with and without transaction  RSS feed

 
Babji Reddy
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
  • 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?
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • 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?
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
  • 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
  • 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?
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!