Handling Transactions in java

It is basically a application in struts. For a specific functionality, it navigates through 5 pages. It involves 4 database tables. in everypage, there are data inserts in the tables and also updates. The issue is, if there is some error in the final page, all the prior transactions should rollback, which is not happening.
I am carrying the same connection throughout this session. The inserts has to happen in the intermediate pages as based on the insert row, a id will be generated and that id is used in the other manipulations for the remaining pages. Pls suggest me how can i acheive a rollback if for any exceptions in the intermediate / final pages.
Pls respond ASAP, its urgent. Thanks
dreams4everAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

elfe69Commented:
It is really not a good idea to keep a database transaction between several web pages because you will never know if the client leaves your pages and jump to any other site. In such a case, your transaction could stay pending for hours...
I think the best way to achieve such multi-pages insertion/update process is to store everything in temporary tables with the sessionID or any other ID and only when the last page is processed to move everything to the production tables
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
dreams4everAuthor Commented:
Hi
Thanks for the suggestion and you are absolutely correct.  but unfortunately the project is in such a stage where it cannot go back for creating temp db tables etc. Is there any otherway other than that to solve this issue ?
0
Mayank SAssociate Director - Product EngineeringCommented:
Yes, you should probably store the information in memory (maybe in Hashtables) of the web application (HttpSession object), and insert them in a bulk when ready. You will run into problems if you keep the connection open for long and if the user gets disconnected through a network time out or something of that sort.
0
Mayank SAssociate Director - Product EngineeringCommented:
Its not required to store it in temp DB tables - I think memory would do but yeah, you need to ensure it is cleaned in case of exceptions otherwise the memory usage will go high.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.