-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: JDBC batch update worked with MySQL 4.0.x, fails with 5.0.x
PostPosted: Wed Aug 23, 2006 2:23 pm 
Newbie

Joined: Fri Jan 20, 2006 4:08 pm
Posts: 2
Location: Titusville, FL
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:3.1.1

Mapping documents:

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:
Code:
WARN : SQL Error: 1064, SQLState: 42000
ERROR: 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 'connection, circuit, id) values (0, '0059eb790d3b81c4010d3b83d6bd0003', 8, 3, 16' at line 1
ERROR: 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:65)
        at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
        at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:202)
        at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:91)
        at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:86)
        at org.hibernate.jdbc.AbstractBatcher.prepareBatchStatement(AbstractBatcher.java:171)
        at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2048)
        at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2427)
        at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:51)
        at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:243)
        at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:227)
        at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:140)
        at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:296)
        at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
        at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1007)
        at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:354)
        at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
        at gov.nasa.ksc.ustdc.cwdmtool.utils.PojoManager.saveOrUpdate(PojoManager.java:419)
        at gov.nasa.ksc.ustdc.cwdmtool.designEngine.DesignEngineManager.saveSystem(DesignEngineManager.java:199)
        at gov.nasa.ksc.ustdc.cwdmtool.design.RunApprovedAction.submitDesign(RunApprovedAction.java:102)
        at gov.nasa.ksc.ustdc.cwdmtool.design.RunApprovedAction.execute(RunApprovedAction.java:55)
        at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:421)
        at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:226)
        at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
        at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:415)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
        at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:362)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:482)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
        at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
        at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
        at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
        at java.lang.Thread.run(Thread.java:595)
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 'connection, circuit, id) values (0, '0059eb790d3b81c4010d3b83d6bd0003', 8, 3, 16' at line 1
        at com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:1099)
        at com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:849)
        at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeBatch(NewProxyPreparedStatement.java:1723)
        at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:58)
        at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:195)
        ... 42 more


Name and version of the database you are using:MySQL 5.0.x

The generated SQL (show_sql=true):
Code:
Hibernate: insert into UniversalComWidgets (version, partId, serialNo, nodeName, facilityLocation, state, parentWidget, psPrimaryObj, psBackupObj, netMgmtObj, rackRoom, rackId, rackEl, parentSlot, source, destination, circuit, measuredLoss, id) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: insert into UniversalComWidgets (version, partId, serialNo, nodeName, facilityLocation, state, parentWidget, psPrimaryObj, psBackupObj, netMgmtObj, rackRoom, rackId, rackEl, parentSlot, source, destination, circuit, measuredLoss, id) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: insert into UniversalComWidgets (version, partId, serialNo, nodeName, facilityLocation, state, parentWidget, psPrimaryObj, psBackupObj, netMgmtObj, rackRoom, rackId, rackEl, parentSlot, source, destination, circuit, measuredLoss, id) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: insert into IoPorts (version, parentWidget, parentPort, portType, channel, connection, circuit, id) values (?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: insert into IoPorts (version, parentWidget, parentPort, portType, channel, connection, circuit, id) values (?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: insert into IoPorts (version, parentWidget, parentPort, portType, channel, connection, circuit, id) values (?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: insert into IoPorts (version, parentWidget, parentPort, portType, channel, connection, circuit, id) values (?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: insert into IoPorts (version, parentWidget, parentPort, portType, channel, connection, circuit, id) values (?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: insert into IoPorts (version, parentWidget, parentPort, portType, channel, connection, circuit, id) values (?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: insert into IoPorts (version, parentWidget, parentPort, portType, channel, connection, circuit, id) values (?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: insert into IoPorts (version, parentWidget, parentPort, portType, channel, connection, circuit, id) values (?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: insert into IoPorts (version, parentWidget, parentPort, portType, channel, connection, circuit, id) values (?, ?, ?, ?, ?, ?, ?, ?)
WARN : SQL Error: 1064, SQLState: 42000
ERROR: 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 'connection, circuit, id) values (0, '0059eb790d3b81c4010d3b83d6bd0003', 8, 3, 16' at line 1
ERROR: Could not synchronize database state with session
org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update


Debug level Hibernate log excerpt:

Hi All,
After upgrading my server to MySQL 5.0.24 from MySQL 4.0.21 (also upgraded driver to mysql-connector-java-5.03 from 3.1.12), I am now experiencing problems during updates with something that worked fine before. Many changes to multiple inter-related objects occurr and I try to save them all in one big transaction.
I saw one post out there that had a similar batch update syntax problem with MySQL 5.0 and they fixed their issue with changing <prop key="hibernate.jdbc.batch_size">0</prop> ... this does not solve my syntax problem. Any ideas what may be different using MySQL 5.0 from 4.0 here?
Thanks,
Dave


Top
 Profile  
 
 Post subject: Reserved Word
PostPosted: Thu Aug 24, 2006 10:46 am 
Newbie

Joined: Fri Jan 20, 2006 4:08 pm
Posts: 2
Location: Titusville, FL
The word "connection" is a reserved word in MySQL 5.0 and not reserved in 4.0, so this becomes a syntax error when used as a column name in the newer version. Problem solved.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.