public String commit(RowSet rs,RowSet rs1,RowSet rs2) throws SQLException {
Connection con = null;
try{
CachedRowSet crs = (CachedRowSet)rs;
CachedRowSet crs1 = (CachedRowSet)rs1;
CachedRowSet crs2 = (CachedRowSet)rs2;
con = ds.getConnection();
con.setAutoCommit(false);
crs.acceptChanges(con);
crs1.acceptChanges(con);
crs2.acceptChanges(con);
con.commit();
}catch(SQLException sql){
con.rollback();
}
finally{
if (con != null)
{
con.close();
}
}
return "success";
} 这种方式处理的话,当crs1.acceptChanges(con)成功,但crs2.acceptChanges(con)失败的话,rollback后,crs1对应的资料还是更新到数据库了。
那位高手遇到过这种情况吗?还是有其它的解决方式。
Connection con = null;
try{
CachedRowSet crs = (CachedRowSet)rs;
CachedRowSet crs1 = (CachedRowSet)rs1;
CachedRowSet crs2 = (CachedRowSet)rs2;
con = ds.getConnection();
con.setAutoCommit(false);
crs.acceptChanges(con);
crs1.acceptChanges(con);
crs2.acceptChanges(con);
con.commit();
}catch(SQLException sql){
con.rollback();
}
finally{
if (con != null)
{
con.close();
}
}
return "success";
} 这种方式处理的话,当crs1.acceptChanges(con)成功,但crs2.acceptChanges(con)失败的话,rollback后,crs1对应的资料还是更新到数据库了。
那位高手遇到过这种情况吗?还是有其它的解决方式。
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货