I think, it would be a wrong of doing like this if u need transaction. If a new request arrives in the middle of a transaction of the previous request, then one
thread(one request) may try to start transaction, while another thread(another request) may try to rollback the transaction. There r two ways to solve this. One is to synchronize the doPost method which is not good for a site with considerable hits. Another way is to open and close the connection in the doPost method. The ConnectionPooling mechanism must be used for obtaining quick connection to the database.
S.Mohamed Yousuff
Originally posted by Celina Joseph:
I create a Connection instance in my init() and destroy it in the destroy().
My servlet allows concurrent access.
My autoCommit() is false.And in my service(doPost), I start a transaction, perform multiple SQL, commit or rollback the transaction.
When another request comes at the time when one request is being executed, what happens ?