This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
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 The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript 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: 41577
    
  54
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