This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
Hi, I have a set of transactions to be performed and incase any of them goofs up I need to rollback. I therefore catch and rollback in the catch for SQLException. However conn.rollback() itself throws a SQLException. I am currently handling it by a try within a catch. The code sample is below : catch (SQLException e) { try{ conn.rollback(); Logger.logProblem(); } catch (SQLException sqle) { String name = "Errror in trying to rollback:" + new java.util.Date(); Logger.logProblem(name); } catch (SQLException sqle) { String name = " SQl Errror:" + new java.util.Date(); Logger.logProblem(name); } } Please let me know if there ia a better way in which this is handeled in applications... thanxs
hi There may be problem in your conn , see whether this object is getting created or not , Coz if conn.rollback(); is throwing the exception then check it with null pls see the code below thanks
catch (SQLException e) { try{ //***************** if(conn != null) //**************** conn.rollback(); Logger.logProblem(); } catch (SQLException sqle) { String name = "Errror in trying to rollback:" + new java.util.Date(); Logger.logProblem(name); } catch (SQLException sqle) { String name = " SQl Errror:" + new java.util.Date(); Logger.logProblem(name); } }