public void testAddStudent
InitialContext context = new InitialContext()
StudentManager sm = (StudentManager)context
for(int i=
sm
if(i >
throw new RuntimeException(
//數據庫依然會插進去數據
}
}
}
public void testAddStudent
InitialContext context = new InitialContext()
StudentManager sm = (StudentManager)context
//JTA的事務管理由UserTransaction管理
UserTransaction utx = (UserTransaction)context
try{
utx
//沒有數據會插入數據庫
for(int i=
sm
if(i >
throw new RuntimeException(
}
}
mit()
}catch(Exception e){
utx
e
}
}
}
From:http://tw.wingwit.com/Article/program/Java/hx/201311/27051.html