java与oracle事务的结合

public boolean execute() {
  //Adapter.DB cc=null;
  Connection conn=null;
  Statement stmt = null;
  try{
   //cc = Adapter.DB.binding("ff6aa24f543043311ca87789ab71619b"); 
   conn = DBSql.open();
   conn.setAutoCommit(false);//取消自动提交
   stmt=conn.createStatement();
   //执行insert或update语句
   stmt.addBatch("update BO_TEST set score=10 where id=13324642");
   stmt.addBatch("update BO_TEST set score=12 where id=13324643");
   stmt.addBatch("update BO_TEST set score='一百' where id=13359038");
   
   stmt.executeBatch();
   conn.commit();
  }catch(Exception e){
   try {
    conn.rollback();
   } catch (SQLException e1) {
    e1.printStackTrace();
   }
   e.printStackTrace();
  }finally{
   //Adapter.DB.close(conn, stmt, null);
   DBSql.close(conn, stmt, null);
  }
  return false;
 }

你可能感兴趣的:(oracle)