我的程序出现这个错误:javax.servlet.ServletException: Could not execute JDBC batch update
我查了,原因来自这个方法:
public void saveOrUpdate(Object obj) throws HibernateException {
Session session = HibernateUtil.currentSession();
if (obj != null) {
Transaction tx = null;
try {
tx = session.beginTransaction();
session.saveOrUpdate(obj);
tx.commit();
} catch (HibernateException e) {
if (tx != null)
tx.rollback();
throw e;
}
}
session.close();
}我再深入调试,就是方法里面的这句:tx.commit();有问题,注释掉这句以后,程序就能往下运行 。
但是如果没有这句,数据就没办法提交了