I have to update 5 tables simultaniously which are inter related with each other. My requirement is if all tables are updated successfully then all the updates will be commited. if any one of the query is failed due to some reason all the queried should be rolledback.
The way I handled the transactions is
I set the auto commit to false
executed the update queries
set the auto commit to true
But I am getting the following error message:
java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Can't start ma
nual transaction mode because there are cloned connections.
at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source
)
at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
at com.microsoft.jdbc.base.BaseConnection.setAutoCommit(Unknown Source)
at org.apache.tomcat.dbcp.dbcp.DelegatingConnection.setAutoCommit(Delega
tingConnection.java:268)
at org.apache.tomcat.dbcp.dbcp.PoolingDataSource$PoolGuardConnectionWrap
per.setAutoCommit(PoolingDataSource.java:293)
the sample code is:
....
connection.setAutoCommit(false);
statement.executeUpdate(query1);
statement.executeUpdate(query2);
statement.executeUpdate(query3);
statement.executeUpdate(query4);
statement.executeUpdate(query5);
connection.setAutoCommit(true);
.....
I've writen the code in the above maner. Because of my code is very lengthy I can't provide the exact code here. But I think this will help you to understand my problem.
Please suggest me a solution to solve this problem. If there is any other way to handle this scenario please suggest me the better way.
Thanking You.