Hello everybody,
I was wondering what is the best way to cope with transaction errors in a
Struts application. I use JDBC to connect to the database. When I try to do
an insert-transaction it looks like the code below the message (sample form the Sun Tutorial).
My question is: what should I do when an update query fails and the client has to submit the query again?
I'm using a Servlet Container (Tomcat 5.0.27) and no EJB's.
Best Regards,
Peter
public void ship (String productId, String orderId, int quantity) {
try {
con.setAutoCommit(false);
updateOrderItem(productId, orderId);
updateInventory(productId, quantity);
con.commit();
} catch (Exception ex) {
try {
con.rollback();
throw new Exception("Transaction failed: " +
ex.getMessage());
} catch (SQLException sqx) {
throw new Exception("Rollback failed: " +
sqx.getMessage());
}
}
}
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]