一般是一个一个语句execute()
然后commit()

解决方案 »

  1.   

    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();
    }
    }