我有一个批量更新功能,它不包含任何GROUP_CONCAT()调用;
UPDATE
product
SET
viewed = ?
WHERE
product_id = ?
如你所见,这是一份准备好的声明。我设置了它的值,然后使用addBatch()方法foreach行添加它。当我的计数达到定义的限制(1000)时,我调用executeBatch()来进行数据库修改。正如您所看到的,在我的批量更新过程中没有group_concat()调用,但是mysql jdbc会抛出此异常。 批量更新和group_concat()的隐藏关系是什么?为什么?我该怎么做才能解决这个问题?减少批量限制或增加group_concat()限制?
我的堆栈跟踪是;
java.sql.BatchUpdateException: Row 276751 was cut by GROUP_CONCAT()
at com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:2054)
at com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:1467)
at datasource.DB.execPreparedStatement(DB.java:480)
at datasource.DB.addBatch(DB.java:467)
at cj.reportsummarydaily.ProductViewed.executeJob(ProductViewed.java:24)
at job.Job.executeCore(Job.java:101)
at job.Job.execute(Job.java:77)
at cj.reportsummarydaily.Main.executeJobMeta(Main.java:35)
at job.JobMeta.execute(JobMeta.java:32)
at cronjob.CronJob.main(CronJob.java:66)
Caused by: java.sql.SQLException: Row 276751 was cut by GROUP_CONCAT()
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1078)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4187)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4119)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2570)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2731)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2815)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2155)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2458)
at com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:2006)
... 9 more
答案 0 :(得分:0)
我找到了& 修复问题。我们的一位前程序员在表产品的更新触发器之前编写了错误的 。因此,当我更新产品表时,触发器会在某些特定记录上引发该异常。我正确地重新编程了触发器,还添加了下面的代码以增加group_concat限制;
SET group_concat_max_len=1024 * 10;