在同一个事务中肯定是可以同时进行insert和delete操作的。
是你写的程序本身就有问题。你好好看看下面的连接 吧。
http://community.csdn.net/Expert/topic/3285/3285254.xml?temp=.0951044

解决方案 »

  1.   

    把insert和delete和在一起写啊,分成两步不行,因为它执行一个后自动消亡(生命周期),与到第二个当然就不识别了
      

  2.   

    在同一个事务中肯定是可以同时进行insert和delete操作的,只要是对数据库有影响的语句就可以写在事务中。
    同意楼上的观点!
      

  3.   

    事务处理里面只能用一个PreparedStatement吧,你改成只用pts,不用pt2,类似我给的例子
    PreparedStatement pts = con.prepareStatement(insertSQL);
    PreparedStatement pts2 = con.prepareStatement(deleteSQL);
        private void testDBT(java.sql.Connection con, String insert, String update)
            throws Exception {
            try {
                con.setAutoCommit(false);
                java.sql.Statement st = con.createStatement();
                st.executeUpdate(insert);
                st.executeUpdate(update);
                con.commit();
            }
            catch (Exception e) {
                con.rollback();
            }
        }
      

  4.   

    String insertSQL = "Insert into table1(col1) values(?)";
    String deleteSQL = "Delete from table1 where col1 = ?";con.setAutoCommit(false);for (int index = 0; index < list.size(); index++)
    {
      PreparedStatement pts = con.prepareStatement(insertSQL);
      pts.setInt(1,index);
      pts.executeUpdate();  pts = con.prepareStatement(deleteSQL);
      pts.setInt(1,index);
      pts.executeUpdate();
    }con.commit();
      

  5.   

    String insertSQL = "Insert into table1(col1) values(?)";
    String deleteSQL = "Delete from table1 where col1 = ?";con.setAutoCommit(false);for (int index = 0; index < list.size(); index++)
    {
      PreparedStatement pts = con.prepareStatement(insertSQL);
      pts.setInt(1,index);
      pts.executeUpdate();  pts = con.prepareStatement(deleteSQL);
      pts.setInt(1,index);
      pts.executeUpdate();
    }con.commit();
    就是这样的