下面代码不知道你是不是能用得上。 try{
conn=ConnDB.getConnection();
conn.setAutoCommit(false);
st=conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
String sql = "INSERT INTO TEAM(TEAM_ID,TEAM_NAME) VALUES ('" + teamid + "','" + teamname + "');";
st.execute(sql); }
catch(SQLException e){
conn.rollback();
e.printStackTrace();
request.setAttribute("errCode",Integer.toString(e.getErrorCode()));
throw new SQLException(e.getMessage());
}
finally{
conn.commit();
st.close();
conn.close();
}
conn=ConnDB.getConnection();
conn.setAutoCommit(false);
st=conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
String sql = "INSERT INTO TEAM(TEAM_ID,TEAM_NAME) VALUES ('" + teamid + "','" + teamname + "');";
st.execute(sql); }
catch(SQLException e){
conn.rollback();
e.printStackTrace();
request.setAttribute("errCode",Integer.toString(e.getErrorCode()));
throw new SQLException(e.getMessage());
}
finally{
conn.commit();
st.close();
conn.close();
}
解决方案 »
- 求助,关于在Java类中清除cookie的问题
- Struts2的Action中获取ServletActionContext.getPageContext()==null
- 急..项目文档需求分析
- 请教,ssh框架中,url标签中参数的值,在action处理类中得不到,怎么办?
- 求问关于SSH2框架的应用,如何手动部署到tomcat上。
- 关于Applet的基础的问题!!!
- 请问在java中如何调用asp.net的webservice??
- java服务器的有关参数获得
- 基本类型如何在方法中引用调用
- 高手请进,俗称的'JS'到底是指什么呢?
- 如何打开J2EE服务器的默认的主页信息???端口有冲突呀!!!!烦死了
- 请问使用hibernate开发客户端程序(Oracle),究竟需要那几个开发包?
1 出现异常,在catch到后就回滚
2 中间某个条件在业务逻辑上不满足逻辑条件,也该回滚