通过jdbc访问sqlserver2000数据库,怎样实现事务处理? 一般是一个一个语句execute()然后commit() 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 try{if (request.getParameter("Id")!=null){String[] delId=request.getParameterValues("delId");conn.setAutoCommit(false);PreparedStatement st=conn.prepareStatement("select Arc_Id,Arc_Name from Arc_Electron where Arc_id=?",ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);PreparedStatement st1=conn.prepareStatement("insert into Arc_Destroy values(?,?,?,?,?)",ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);for(int i=0;i<delId.length;i++){st.setString(1,delId[i]);rs=st.executeQuery();if (rs.next()){st1.clearParameters();st1.setString(1,rs.getString(1));st1.setString(2,rs.getString(2));st1.setString(3,AppPer);st1.setString(4,tool.getDate());st1.setString(5,"");st1.executeUpdate(); rs.deleteRow();}st.clearParameters();}conn.commit();conn.setAutoCommit(true);}}catch(SQLException e){str="delArc"+e.toString();try{conn.rollback();conn.setAutoCommit(true);}catch(SQLException ed){str=ed.getMessage();}} 求大大帮忙! jsp 图片插入 MyEclipse导入项目问题 启动EXE~!小妹求教 关于一个时间倒计数的线程 问一下大家用什么工具开发jsp啊?那java方法和函数如何查? 如何定时更新页面中的数据? 请问一下这是什么意思? ckeditor如何实现标注功能 图片按钮传action的问题 怎样实现点击"保存"后把页面上的表格直接生成excel文件保存到本地,而不在服务器上生成文件?(页面上有其他东东都不要只要表格) 急:如何在页面刷新时不触发onUnload事件?
{
if (request.getParameter("Id")!=null)
{
String[] delId=request.getParameterValues("delId");
conn.setAutoCommit(false);
PreparedStatement st=conn.prepareStatement("select Arc_Id,Arc_Name from Arc_Electron where Arc_id=?",ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
PreparedStatement st1=conn.prepareStatement("insert into Arc_Destroy values(?,?,?,?,?)",ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
for(int i=0;i<delId.length;i++)
{
st.setString(1,delId[i]);
rs=st.executeQuery();
if (rs.next())
{
st1.clearParameters();
st1.setString(1,rs.getString(1));
st1.setString(2,rs.getString(2));
st1.setString(3,AppPer);
st1.setString(4,tool.getDate());
st1.setString(5,"");
st1.executeUpdate();
rs.deleteRow();
}
st.clearParameters();
}
conn.commit();
conn.setAutoCommit(true);
}
}
catch(SQLException e)
{
str="delArc"+e.toString();
try
{
conn.rollback();
conn.setAutoCommit(true);
}
catch(SQLException ed)
{
str=ed.getMessage();
}
}