org.hibernate.exception.GenericJDBCException: could not inspect JDBC autocommit mode
org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:82)
org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:70)
org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:29)
org.hibernate.jdbc.JDBCContext.afterNontransactionalQuery(JDBCContext.java:338)
org.hibernate.impl.SessionImpl.afterOperation(SessionImpl.java:398)
org.hibernate.impl.SessionImpl.list(SessionImpl.java:852)
org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)
com.dfnm.hibernate.mapping.ReferDAO.findAll(ReferDAO.java:240)
com.dfnm.struts.action.ReferSelAction.execute(ReferSelAction.java:65)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
------解决方法--------------------------------------------------------
看样子应该是事务处理出现了问题...仔细检查下代码...
------解决方法--------------------------------------------------------
事务处理有问题。不能把事务定义为类的成员变量。
private Session s; public void referup(int id,int uid){ if(s==null||!s.isOpen()) { s=(Session) this.getSession(); } Transaction tr=s.beginTransaction(); try { Refer refer=(Refer)s.load(Refer.class, id); Users user=(Users)s.load(Users.class, uid); refer.setUsersByReferAnswerid(user); refer.setReferState(2); s.update(refer); tr.commit(); } catch (HibernateException e) { // TODO Auto-generated catch block e.printStackTrace(); tr.rollback(); } s.close(); }