Hi,
Is it a bug?
I recently got the same problem. I use the following pseudo code to send an array of data records to one database:
...
var myDataRecords = [...]; // array with data records
var myInsertQuery = 'INSET INTO ...';
prepSt = conn.prepareStatement(myInsertQuery);
if (myDataRecords.length > 0){ prepSt.setBatchSize(myDataRecords.length); for(var i = 0; i < myDataRecords.length; i++){ prepSt.setInt(1, myDataRecords[i].dataField_1); prepSt.setString(2, myDataRecords[i].dataField_2); ... prepSt.setString(n, myDataRecords[i].dataField_n); prepSt.addBatch(); } prepSt.executeBatch();
}
prepSt.close();
...It works fine but if the data record array has only one record this code trows exception at addBatch():
"PreparedStatement.addBatch: bulk insert not enabled".
Is a batching with a batch size = 1 a special case? The special cases make a code ugly.
.
Please tell me that I am wrong.