当前位置: 代码迷 >> Java Web开发 >> SQLGrammarException: Could not execute JDBC batch update
  详细解决方案

SQLGrammarException: Could not execute JDBC batch update

热度:733   发布时间:2016-04-17 12:30:35.0
hibernate添加、修改操作报错,项目在即,请各位帮忙!先谢过
exception 

org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update
org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:202)
org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:235)
org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:140)
org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:297)
org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
org.hibernate.impl.SessionImpl.flush(SessionImpl.java:985)
org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:333)
org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
com.brilliance.qfb.struts.action.LinkAction.doPost(LinkAction.java:108)
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)





// 修改,LinkDAO是Myeclipse自动生成的
int id = Integer.parseInt(request.getParameter("id"));
LinkDAO dao = new LinkDAO();
Link link = dao.findById(id);
int index = Integer.parseInt(request.getParameter("index"));
String title= request.getParameter("title");
String url = request.getParameter("url");
String logo = request.getParameter("logo");

link.setIndex(index);
link.setTitle(title);
link.setUrl(url);
link.setLogo(logo);

Transaction tx = dao.getSession().beginTransaction();
dao.attachDirty(link);
tx.commit();
dao.getSession().close();



在tx.commit()的时候报错

------解决方案--------------------
你最好先把link里的属性值打印出来,看看是不是你所需要的值,然后把值跟配置文件里的字段描述再对一遍,看看是否符合要求,最后你再看看你所插入的值是否与数据库表字段的限制相冲突
------解决方案--------------------
http://qiufubin.blog.sohu.com/75392869.html
问题已经解决,请到我的博客中查看解决办法
  相关解决方案