Source:
private void createDiscontinueOrders(JdbcConnection connection, List<DiscontinuedOrder> discontinuedOrders) throws CustomChangeException, SQLException, DatabaseException { final int batchSize = 1000; int index = 0; PreparedStatement insertStatement = null; Boolean autoCommit = null; try { autoCommit = connection.getAutoCommit(); connection.setAutoCommit(false); insertStatement = connection.prepareStatement("Insert into orders(previous_order_id, concept_id, patient_id, encounter_id, " + "creator, date_created, discontinued_date, discontinued_by, discontinued_reason, discontinued_reason_non_coded, uuid) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); for (DiscontinuedOrder discontinuedOrder : discontinuedOrders) { insertStatement.setInt(1, discontinuedOrder.previousOrderId); insertStatement.setInt(2, discontinuedOrder.conceptId); insertStatement.setInt(3, discontinuedOrder.patientId); insertStatement.setInt(4, discontinuedOrder.encounterId); insertStatement.setInt(5, discontinuedOrder.creator); insertStatement.setDate(6, discontinuedOrder.dateCreated); insertStatement.setDate(7, discontinuedOrder.discontinuedDate); insertStatement.setInt(8, discontinuedOrder.discontinuedById); insertStatement.setInt(9, discontinuedOrder.discontinuedReasonId); insertStatement.setString(10, discontinuedOrder.discontinuedReasonNonCoded); insertStatement.setString(11, UUID.randomUUID().toString()); insertStatement.addBatch(); if(index % batchSize == 0) { insertStatement.executeBatch(); } index++; } insertStatement.executeBatch(); connection.commit(); } catch (DatabaseException e) { handleError(connection, e); } catch (SQLException e) { handleError(connection, e); } finally { if(autoCommit != null) { connection.setAutoCommit(autoCommit); } if(insertStatement != null) { insertStatement.close(); } } }

Target:
private void createDiscontinueOrders(JdbcConnection connection, List<DiscontinuedOrder> discontinuedOrders) throws CustomChangeException, SQLException, DatabaseException { final int batchSize = 1000; int index = 0; PreparedStatement insertStatement = null; Boolean autoCommit = null; try { autoCommit = connection.getAutoCommit(); connection.setAutoCommit(false); insertStatement = connection.prepareStatement("Insert into orders(previous_order_id, concept_id, patient_id, encounter_id, " + "creator, date_created, date_stopped, discontinued_by, discontinued_reason, discontinued_reason_non_coded, uuid) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); for (DiscontinuedOrder discontinuedOrder : discontinuedOrders) { insertStatement.setInt(1, discontinuedOrder.previousOrderId); insertStatement.setInt(2, discontinuedOrder.conceptId); insertStatement.setInt(3, discontinuedOrder.patientId); insertStatement.setInt(4, discontinuedOrder.encounterId); insertStatement.setInt(5, discontinuedOrder.creator); insertStatement.setDate(6, discontinuedOrder.dateCreated); insertStatement.setDate(7, discontinuedOrder.dateStopped); insertStatement.setInt(8, discontinuedOrder.discontinuedById); insertStatement.setInt(9, discontinuedOrder.discontinuedReasonId); insertStatement.setString(10, discontinuedOrder.discontinuedReasonNonCoded); insertStatement.setString(11, UUID.randomUUID().toString()); insertStatement.addBatch(); if(index % batchSize == 0) { insertStatement.executeBatch(); } index++; } insertStatement.executeBatch(); connection.commit(); } catch (DatabaseException e) { handleError(connection, e); } catch (SQLException e) { handleError(connection, e); } finally { if(autoCommit != null) { connection.setAutoCommit(autoCommit); } if(insertStatement != null) { insertStatement.close(); } } }