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 How to handle connection failure 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 "How to handle connection failure" Watch "How to handle connection failure" New topic

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

Joined: Mar 22, 2005
Posts: 42965
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).
V Patil
Ranch Hand

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

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:
subject: How to handle connection failure
It's not a secret anymore!