用SQL语句
UNION 运算符使您得以将两个或多个 SELECT 语句的结果组合成一个结果集。
SELECT * FROM Table1
UNION
SELECT * FROM Table2下面是结果集:ColumnA  ColumnB
-------  --------
abc      1
def      2
ghi      3
jkl      4
mno      5

解决方案 »

  1.   

    1.jsp
    //开始一个事务
    Connection.setAutoCommit(false);
    do the transaction//你在这中间写你的事务代码。
    Connection.commit();
    //事务完成,提交事务
    2.写个存储过程
    sql server:
    create procedure test
    As
       begin tran
       insert ...
       if @@error<> 0  goto Err
       delete...
       if @@error<> 0  goto Err
       update..
       if @@error<> 0  goto Err
       commit
       return
    Err:
       rollback
      

  2.   

    用事务啊Connection.setAutoCommit(false);
    try{  do the transaction//你在这中间写你的事务代码。  Connection.commit();
    }
    catch(Excepiton e) {
      Connection.rollback();
    }