我有一个 JDBC 应用程序,要将插入语句转换为批处理,我在 MySQL 连接字符串中使用了 rewriteBatchedStatements=true
,但我还需要将批处理大小限制为 100。我该怎么做?
最佳答案
在服务器端,max_allowed_packet
将限制由 rewriteBatchedStatements
组合在一起的 INSERT
的数量。根据 5.1.8 Server System Variables :
The maximum size of one packet or any generated/intermediate string, or any parameter sent by the mysql_stmt_send_long_data() C API function. The default is 64MB.
如果您需要更细粒度的控制,您必须使用 JDBC,例如通过在每 N 行之后调用 executeBatch()
。
关于java - 限制 jConnector 中的 MySQL 批处理大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53300333/