?? jtabean.java
字號:
package jtajts;import javax.ejb.*;import javax.transaction.*;import javax.naming.*;public class JtaBean implements SessionBean { SessionContext sessionContext; public void ejbCreate() throws CreateException { } public void ejbRemove() { } public void ejbActivate() { } public void ejbPassivate() { } public void setSessionContext(SessionContext sessionContext) { this.sessionContext = sessionContext; } //一個事務處理示例函數,這里只是實例 public String myTransation() { UserTransaction userTran = sessionContext.getUserTransaction(); String ret="myTransation is start\n"; try{ userTran.begin(); ret=ret+"The first business is begin:\n"; //這里放第一個業務方法first business method() ret=ret+"The first business is done:\n"; ret=ret+"The second business is begin:\n"; //這里放第二個業務方法second business method() ret=ret+"The second business is done:\n"; userTran.commit(); ret=ret+"myTransation is over!\n"; }catch(Exception e){ try{ userTran.rollback(); }catch(SystemException sysex){ throw new EJBException( "Rollback失敗:"+sysex.toString()); } } return ret; }}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -