File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes problem of rollback() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "problem of rollback()" Watch "problem of rollback()" New topic

problem of rollback()

payal Jain
Ranch Hand

Joined: Dec 20, 2007
Posts: 50
i have an application of sending an card from one employee to other.
On page 1:Employee selectes an Card
page 2:He fills the info like his name,mail Id ,reciptents mail id ,name etc..

When he clicks on "Send" button the data base table gets updated with the information filled by the person on the page and then the mail is send to the reciptent saying he has recieve an card.
Now when there is Exception while sending mail i need to do rollBack for the entry which I recently added.
How can I do that ,
Any suggestion is appreciated.
Paul Sturrock

Joined: Apr 14, 2004
Posts: 10336

You can wrap the whole operation in a transaction. See JTA.

One thought though - email is not a guarenteed transport mechanism so do you really need to care if the email can't be sent?

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
payal Jain
Ranch Hand

Joined: Dec 20, 2007
Posts: 50
can you just help me out with example...
I saw the link you send ,but din't understood
payal Jain
Ranch Hand

Joined: Dec 20, 2007
Posts: 50
please help me with some suggestions.
I really need it urgently.
Vinod K Singh
Ranch Hand

Joined: Sep 30, 2008
Posts: 198
Set autoCommit(false) for database connection. Now do the commit/rollback based on the success of insert and email sent.

My Blog
Meet Gaurav
Ranch Hand

Joined: Oct 08, 2008
Posts: 492
Explain me more About your Application
I agree. Here's the link:
subject: problem of rollback()
It's not a secret anymore!