In my code, I want to the following two queries as a trasaction. If any
of the two queries failed, the database will roll back both queries.How
to make two queries as one trasaction?
// will the code below regard query1 and query2 as trasaction?
query1 = "delete from table1";
query2 = "insert into table1 values ("a1, "a2);
statement1.executeQuery(query1);
statement1.executeQuery(query2);
conn.commit();
// If I don't issue a commit() explictly, will the above two queries be
commited automatically?
Thanks a lot!
Thomas Fritsch - 02 Aug 2005 01:07 GMT
> In my code, I want to the following two queries as a trasaction. If any
> of the two queries failed, the database will roll back both queries.How
[quoted text clipped - 14 lines]
>
> Thanks a lot!
What about reading the javadoc of java.sql.Connection?
Look at setAutoCommit(boolean)

Signature
"TFritsch$t-online:de".replace(':','.').replace('$','@')
steve - 08 Aug 2005 23:35 GMT
> In my code, I want to the following two queries as a trasaction. If any
> of the two queries failed, the database will roll back both queries.How
[quoted text clipped - 14 lines]
>
> Thanks a lot!
FFS
Connection.autoCommit(false);
read it , understand it.