【问题标题】:java.sql.BatchUpdateException: Row x was cut by GROUP_CONCAT()java.sql.BatchUpdateException:第 x 行被 GROUP_CONCAT() 剪切
【发布时间】:2014-12-24 09:02:46
【问题描述】:

我有一个不包含任何 GROUP_CONCAT() 调用的批量更新函数;

UPDATE 
    product 
SET 
    viewed = ? 
WHERE 
    product_id = ? 

如您所见,这是一个准备好的声明。我正在设置它的值,然后使用 addBatch() 方法为每一行添加它。当我的计数达到定义的限制(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

【问题讨论】:

    标签: mysql jdbc group-concat batch-updates


    【解决方案1】:

    我发现并修复了问题。我们的一位前程序员写了一个错误 在更新表产品上的触发器之前。因此,当我更新产品表时,触发器会在某些特定记录上引发该异常。我正确地重新编程了触发器也在下面添加了代码以增加 group_concat 限制;

    SET group_concat_max_len=1024 * 10;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-04-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多