SQL Error: 1064, SQLState: 42000 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version

-- ::, WARN  [org.hibernate.util.JDBCExceptionReporter:] - SQL Error: , SQLState:
-- ::, ERROR [org.hibernate.util.JDBCExceptionReporter:] - 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 'update, id) values ('sdf', 'sdf', 'asdfsd', '-- ::', 23)' at line
-- ::, ERROR [org.hibernate.event.def.AbstractFlushingEventListener:] - Could not synchronize database state with session
org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:)
at org.hibernate.ejb.AbstractEntityManagerImpl$.beforeCompletion(AbstractEntityManagerImpl.java:)
at com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple.beforeCompletion(SynchronizationImple.java:)
at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.beforeCompletion(TwoPhaseCoordinator.java:)
at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.end(TwoPhaseCoordinator.java:)
at com.arjuna.ats.arjuna.AtomicAction.commit(AtomicAction.java:)
at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:)
at com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.commit(BaseTransaction.java:)
at com.arjuna.ats.jbossatx.BaseTransactionManagerDelegate.commit(BaseTransactionManagerDelegate.java:)
at org.jboss.aspects.tx.TxPolicy.endTransaction(TxPolicy.java:)
at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:)
at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:)
at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:)
at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:)
at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:)
at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:)
at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:)
at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:)
at org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:)
at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:)
at org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandler.java:)
at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:)
at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:)
at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:)
at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:)
Caused by: 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 'update, id) values ('sdf', 'sdf', 'asdfsd', '-- ::', 23)' at line
at com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:)
at com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:)
at com.mysql.jdbc.jdbc2.optional.StatementWrapper.executeBatch(StatementWrapper.java:)
at org.jboss.resource.adapter.jdbc.WrappedStatement.executeBatch(WrappedStatement.java:)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:)
... more
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 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 'update, id) values ('sdf', 'sdf', 'asdfsd', '-- ::', 23)' at line
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:)
at com.mysql.jdbc.Util.getInstance(Util.java:)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:)
at com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:)
... more

  出现上面异常的原因:是因为EJB实体类中有一个自动是update,它与数据库表关联映射。update是sql语句中的关键字,因此会出错。

  总结:在网上搜索了一下,这类异常大部分都是sql语句有问题。可以查看该语句中是否有关键字,拼接是否有错(引号),字段类型等。

上一篇:[转] ImageView的android:adjustViewBounds属性


下一篇:IOS 8 关于 Touch ID