SQL Batch Insert

Batch inserts are used to achieve high performance inserts. You may achieve up to ten times the throughput over a standard insert. A batch size of 100 may be effective.


jdbc callpurpose
PreparedStatement.addBatch()Called after setting all the parameters for the insert statement. Basically called in place of executeUpdate()
PreparedStatement.executeBatch()Called after adding all requests to the batch. Processes the batch.


PreparedStatement stmt = conn.prepareStatement("insert into persons (name, age, occupation) values ('bob', ?, ?)")
for (int i = 0; i < 100; i++) {
	stmt.setInt(1, i);
	stmt.setString(2, "artist");