我正在尝试从准备好的语句中添加批处理,精确到 3000 次,但是当调用 executebatch()
时,返回的受影响行数为 2048,这发生在值添加批处理中大于 2048 的调用语句。从哪里返回计数 2048,我无法猜测。有人可以帮我解决这个问题吗?
这是我的代码:
while (resultSet.next()) {
for (int i = 0,j=0; i < noOfColumns && j < noOfColumns; i++) {
//Setting values here for preparedStatement using setString()
}
pstmt.addBatch(); ==> this is called for more than 3000 times
try {
if(++count % batchSize == 0){
updatedCnt=pstmt.executeBatch(); ==> Here batch size is set to 3000 and executebatch returns 2048
successRowCnt = successRowCnt + updatedCnt.length;
}
if (count ==numberofRowsForCloning) {
isResultMatch = false;
break;
}
}
}
最佳答案
Teiid 的默认限制 driver批量插入是 2048。
From Doc:
MaxPreparedInsertBatchSize The max size of a prepared insert batch. 2048
尝试将属性 MaxPreparedInsertBatchSize
配置为您需要的大小。
请记住,这通常仅限于处理内存。
关于java - preparedstatement 的 executebatch() 不返回添加的批处理数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53223079/