A preparedStatement batch is similar to the Statement batch; however, a preparedStatement batch always works off the same prepared statement, and you only change the parameters to that statement.
The following is an example that uses a preparedStatement batch.
connection.setAutoCommit(false); PreparedStatement statement = connection.prepareStatement("INSERT INTO TABLEX VALUES(?, ?)"); statement.setInt(1, 1); statement.setString(2, "Cujo"); statement.addBatch(); statement.setInt(1, 2); statement.setString(2, "Fred"); statement.addBatch(); statement.setInt(1, 3); statement.setString(2, "Mark"); statement.addBatch(); int [] counts = statement.executeBatch(); connection.commit();