org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update

来源:互联网 发布:卖家加入农村淘宝 编辑:程序博客网 时间:2024/04/28 03:50
org.apache.jasper.JasperException: org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch updateorg.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:522)org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:416)org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

root cause

org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch updateorg.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:70)org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:181)org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:226)org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:136)org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:274)org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)org.hibernate.impl.SessionImpl.flush(SessionImpl.java:730)org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:324)org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:86)com.swl.hibernate.pojo.FinanceOperate.insert(FinanceOperate.java:41)org.apache.jsp.AddFinance_005fdo_jsp._jspService(AddFinance_005fdo_jsp.java:109)org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)javax.servlet.http.HttpServlet.service(HttpServlet.java:717)org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

root cause

java.sql.BatchUpdateException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'declare, input, output, userid, id) values ('2', '2', '2012年03月31日  17:15:' at line 1com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:2016)com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:1452)org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:57)org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:174)org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:226)org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:136)org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:274)org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)org.hibernate.impl.SessionImpl.flush(SessionImpl.java:730)org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:324)org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:86)com.swl.hibernate.pojo.FinanceOperate.insert(FinanceOperate.java:41)org.apache.jsp.AddFinance_005fdo_jsp._jspService(AddFinance_005fdo_jsp.java:109)org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)javax.servlet.http.HttpServlet.service(HttpServlet.java:717)org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

弄了两个多小时,居然是由于数据表中的字段declare和系统关键字一样,修改下declare为其他的名称,就好了。