Rollback not working with JDBC when error occur
Posted by: Kapil Dhakad
Date: July 11, 2005 10:34PM

Hi,

I am using MySQL with JDBC. For connectivity I am using MySQL ConnectorJ
I have to execute group of statements. Like

insert into table1 ( pri_key, val1, val2, ...... );
insert into table 2 (pri_key_of_table1, ....... );
insert into table 3 (pri_key_of_table1, ....... );
insert into table 4 (pri_key_of_table1, ....... );

I am not interested in making batch of these statement because result of first query will use for insertion of record in other tables.

My question is...
============
During insertion using JDBC.. if any error occur then all insertion should rollback. Currently code is like

try {
con.setAutoCommit(false);
.
.
pst1.executeUpdate(insert_statement_1);
.
.
pst2.executeUpdate(inserst_statement_2);
.
.
con.commit();
}
catch(Exception e)
{
con.rollback();
e.printStatckTrace();
}

But it seems that above code for rollback is not working.
Please require help urgently

Thanks in advance
- Kapil Dhakad

Options: ReplyQuote


Subject
Written By
Posted
Rollback not working with JDBC when error occur
July 11, 2005 10:34PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.