try {
daoManager.startTransaction();
daoManager.commitTransaction();
}
catch(Exception e){
e.printStackTrace();
}
finally {
daoManager.endTransaction();
}
}不放在finally放在哪?你就是用hibernate也是在finally里面HibernateSessionFactory.closeSession()放在finally里面是为了避免发生异常时连接,事务等没有关闭,比如在try里面..放catch里面是不好滴.那样如果没异常你不是就不关闭了??所以要放finally里面..
daoManager.startTransaction();
daoManager.commitTransaction();
}
catch(Exception e){
e.printStackTrace();
}
finally {
daoManager.endTransaction();
}
}不放在finally放在哪?你就是用hibernate也是在finally里面HibernateSessionFactory.closeSession()放在finally里面是为了避免发生异常时连接,事务等没有关闭,比如在try里面..放catch里面是不好滴.那样如果没异常你不是就不关闭了??所以要放finally里面..
public void commitTransaction(); /**
* Ends all transactions currently started for all DAO contexts
* managed by this DaoManager. If any transactions have not been
* successfully committed, then those remaining will be rolled back.
*/If any transactions have not been
* successfully committed, then those remaining will be rolled back.这句话就说了.如果发生异常,事务就会回滚
问题解决..50分全是我的哟..结贴,,结贴
daoManager.startTransaction();
.............................
id = this.getzdbh(".....","","",13);// 存储过程 获取id
..
..
form.setChr_qyid(id);
insert("insertjcjl",form); //第一个操作/...
..
...
insert("insertjcjl",form);//第二个.....三..四...
daoManager.commitTransaction();
}
catch(Exception e){
e.printStackTrace();
}
finally {
daoManager.endTransaction();
}
return b;
}
不知有没有大虾能指点指点!分一定给!!