⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 transaction .txt

📁 jdbc transaction processing
💻 TXT
字号:
public boolean addSeatInfo(TSeatInfo ts,String OrderDetailID)throws Exception
{
   boolean b=false;
   Connection conn=null;
   PreparedStatement ps = null;
   Statement st = null;
   ResultSet rs=null;
   try
   {
    conn = DBMgr.getInstance().getConn(); 
    conn.setAutoCommit(false);
   
    String sql="insert into t_seat_info(seq_seat_info_id,Creator,CreateTime,SeatDesc,WhichSell,WhoSell,WhenSell,Num)"
     +"values(seq_seat_info.nextval,?,sysdate,?,?,?,sysdate,?)";
    ps = conn.prepareStatement(sql);
    ps.setString(1,ts.getCreator());
    ps.setString(2,ts.getSeatDesc());
    ps.setString(3,ts.getWhichSell());
    ps.setString(4,ts.getWhoSell());
    ps.setFloat(5,ts.getNum());
    ps.executeUpdate();
   
    st = conn.createStatement();
    String key="";
    rs= st.executeQuery("select seq_seat_info.currval from dual");
    if(rs.next())
    {
     key=rs.getString(1);
    }
   
    sql="update t_order_detail set seq_seat_info_id=? where seq_order_detail_id=?";
    ps = conn.prepareStatement(sql);
    ps.setString(1,key);
    ps.setString(2,OrderDetailID);   
    ps.executeUpdate();
   
    conn.commit();
    b=true;
   
   }
   catch(Exception e)
   {   
    conn.rollback();
    e.printStackTrace();
   }
   finally
   {
    if(ps!=null)
    {
     ps.close();
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -