EJB事务的讨论
一个容器管理事务的无状态会话Bean,事务属性为Required
业务方法线程sleep了15 s,应用服务器交易超时为10s,
public void insertData() {
try {
Connection connection = connection();
Statement stmt = connection.createStatement();
String upd = "insert into student(stuid,stu_name) values('98','sdsd')";
try{
Thread.sleep(15*1000);
}catch(Exception e){
e.printStackTrace();
}
stmt.execute(upd);
} catch (Exception e) {
e.printStackTrace();
}finally{
System.out.println("rollback only? "+ctx.getRollbackOnly());
}
}
按道理这个事务会交易超时导致回滚,但是实际却不是这样的,在weblogic9上,交易却没回滚,数据库记录还是插入了,SUN的应用服务器也是这样,当然都调了事务超时时间为10s,百思不得其解