Two Laptop Bag*
The moose likes JDBC and the fly likes How to handle connection failure Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "How to handle connection failure" Watch "How to handle connection failure" New topic
Author

How to handle connection failure

V Patil
Ranch Hand

Joined: Oct 04, 2008
Posts: 36
I am using several insert statements in a method in Java.
If the connection fails in between I want to roll back the inserted rows.
I cant use con.rollback(), because there is no connection.
How to handle such situation?
Thanks in advance.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42276
    
  64
If no explicit commit has been given at the time the connection goes away, then the transaction is automatically rolled back by the server. The client doesn't need to do anything about it (apart form handling the client-side aspects).


Ping & DNS - my free Android networking tools app
V Patil
Ranch Hand

Joined: Oct 04, 2008
Posts: 36
Thanks a lottt for resolving my query.
Srikanth Nalam
Greenhorn

Joined: Feb 23, 2010
Posts: 20
just add to this, transaction auto commit should be false.


Thanks & Regards,
Srikanth Nalam.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to handle connection failure