rewriteBatchedStatements = true

时间:2016-01-21 15:08:58

标签: java mysql hibernate mariadb

我想通过批量插入来提高性能。基于互联网,我需要将rewriteBatchedStatements = true作为连接字符串的一部分。没有一切正常,但添加后我得到错误。

(错误在下面,从日志中删除了表/字段名,其中一个是`value`,因为我调试的原因是保留字,另一个是`id`,其他是不是reserverd字)

我已经尝试使用hibernate.dialect作为org.hibernate.dialect.MySQLDialect / MySQL5Dialect / MySQL5InnoDBDialect。不知道下一步该尝试什么,因此提出这个问题。

  

引起:org.mariadb.jdbc.internal.util.dao.QueryException:SQL语法中有错误;查看与您的MySQL服务器版本对应的手册,以获得正确的语法,以便使用接近的值(2,' 2016-01-21 16:18:42.82',' 2016- 01-21 16:18:42.82',2157838336,NULL,'在第1行   查询是:   插入TABLENAME(FIELD1,FIELD2,FIELD3,FIELD4,FIELD5,FIELD6)值(?,?,?,?,?,?),参数:[1,' 2016-01-21 16:18:42.817 ',' 2016-01-21 16:18:42.817',2157838336,NULL,223678]       在org.mariadb.jdbc.internal.protocol.AbstractQueryProtocol.getResult(AbstractQueryProtocol.java:475)〜[mariadb-java-client-1.3.4.jar:?]       在org.mariadb.jdbc.internal.protocol.AbstractQueryProtocol.result(AbstractQueryProtocol.java:396)〜[mariadb-java-client-1.3.4.jar:?]       在org.mariadb.jdbc.internal.protocol.AbstractQueryProtocol.executeQuery(AbstractQueryProtocol.java:360)〜[mariadb-java-client-1.3.4.jar:?]       在org.mariadb.jdbc.MariaDbStatement.execute(MariaDbStatement.java:320)〜[mariadb-java-client-1.3.4.jar:?]       在org.mariadb.jdbc.MariaDbStatement.executeBatch(MariaDbStatement.java:1236)〜[mariadb-java-client-1.3.4.jar:?]       在com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeBatch(NewProxyPreparedStatement.java:2544)〜[c3p0-0.9.5.1.jar:0.9.5.1]       在org.hibernate.engine.jdbc.batch.internal.BatchingBatch.performExecution(BatchingBatch.java:127)~ [hibernate-core-4.3.11.Final.jar:4.3.11.Final]       在org.hibernate.engine.jdbc.batch.internal.BatchingBatch.doExecuteBatch(BatchingBatch.java:114)〜[hibernate-core-4.3.11.Final.jar:4.3.11.Final]       在org.hibernate.engine.jdbc.batch.internal.AbstractBatchImpl.execute(AbstractBatchImpl.java:163)〜[hibernate-core-4.3.11.Final.jar:4.3.11.Final]       在org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl.executeBatch(JdbcCoordinatorImpl.java:226)~ [hibernate-core-4.3.11.Final.jar:4.3.11.Final]       在org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:484)〜[hibernate-core-4.3.11.Final.jar:4.3.11.Final]       在org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:351)〜[hibernate-core-4.3.11.Final.jar:4.3.11.Final]       在org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:350)〜[hibernate-core-4.3.11.Final.jar:4.3.11.Final]       在org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:56)〜[hibernate-core-4.3.11.Final.jar:4.3.11.Final]       在org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1258)〜[hibernate-core-4.3.11.Final.jar:4.3.11.Final]       在org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:425)〜[hibernate-core-4.3.11.Final.jar:4.3.11.Final]       在org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.beforeTransactionCommit(JdbcTransaction.java:101)〜[hibernate-core-4.3.11.Final.jar:4.3.11.Final]       在org.hibernate.engine.transaction.spi.AbstractTransactionImpl.commit(AbstractTransactionImpl.java:177)〜[hibernate-core-4.3.11.Final.jar:4.3.11.Final]       在org.hibernate.jpa.internal.TransactionImpl.commit(TransactionImpl.java:77)〜[hibernate-entitymanager-4.3.11.Final.jar:4.3.11.Final]       ... 9更多

版本: hibernate 4.3.11.Final,c3p0 0.9.5.1,mariadb-java-client 1.3.4,mysql 5.6.21

编辑:HA!,我能够通过在AbstractQueryProtocol中设置断点并在堆栈跟踪中检查MasterProtocol中的queriesObj字段来查看完整查询。将分析它们,可能错误更有意义,因为现在我看到所有插入。

EDIT2:嗯,当它们在查询数组中时,插件看起来不错。不确定mariadb-java-client org.mariadb.jdbc.internal.packet.send.SendTextQueryPacket line 120->的这一部分。有错误吗?

                queries.get(0).writeFirstRewritePart(stream);
                int lastPartLength = queries.get(0).writeLastRewritePartLength();
                for (int i = 1; i < queries.size(); i++) {
                    if (pos.checkRewritableLength(queries.get(i).writeToRewritablePartLength(rewriteOffset) + lastPartLength)) {
                        queries.get(i).writeToRewritablePart(stream, rewriteOffset);
                        queryNumberSend++;
                    }
                }
                queries.get(0).writeLastRewritePart(stream);

EDIT3:使用调试信息自己构建mariadb客户端,似乎查询是:

插入TABLENAME(FIELD1,FIELD2,FIELD3,FIELD4,FIELD5,FIELD6)值(6个值),(FIELD1,FIELD2,FIELD3,FIELD4,FIELD5,FIELD6)值(6个其他值),(FIELD1,FIELD2) ,FIELD3,FIELD4,FIELD5,FIELD6)值(6个值),等等。 据我所知,正确的形式将是 插入TABLENAME(FIELD1,FIELD2,FIELD3,FIELD4,FIELD5,FIELD6)值(6个值),(另一组值),(另一组值)

0 个答案:

没有答案