Java ExecuteBatch() inserts only 1 row

Viewed 5103

My code is very simple. but after running executeBatch() only 1 row gets into the DB.

The code is below:

//INSIDE LOOP: 
{
ps = conn.prepareStatement("INSERT INTO NK_EVENT_DATA VALUES(?,?,?,?,?,?,?);

// setting bind variable values
ps.setLong(1, ed_fi_uid);
ps.setString(2 , ed_date);
ps.setString(3, ed_hash_key);
ps.setLong(4 , ed_et_uid);
ps.setLong(5, ed_etn_uid);

ps.addBatch();
}
//LOOP ENDS

ps.executeBatch();

However, only one record gets inserted instead of the 5 records.

3 Answers
Related