Source:
<code>public void upsertTransaction (LinkedHashMap<String, ArrayList<JsonElement>> aggregation, LinkedHashMap<String, ArrayList<JsonElement>> lastData, String destination, String tableName, String tableSuffix, String uniqueKey, String timestampKey, String timestampFormat, boolean attrNativeTypes) throws CygnusPersistenceError, CygnusBadContextData, CygnusRuntimeError, CygnusPersistenceError{ Connection connection = null; PreparedStatement upsertPreparedStatement = null; PreparedStatement insertPreparedStatement = null; int insertedRows[]; try { connection = driver.getConnection(destination); connection.setAutoCommit(false); String insertQuery = SQLQueryUtils.sqlInsertQuery(aggregation, tableName, sqlInstance, destination).toString(); PreparedStatement insertStatement = null; insertStatement = connection.prepareStatement(insertQuery); insertPreparedStatement = SQLQueryUtils.addJsonValues(insertStatement, aggregation, attrNativeTypes); insertedRows = insertPreparedStatement.executeBatch(); String upsertQuery = SQLQueryUtils.sqlUpsertQuery(aggregation, lastData, tableName, tableSuffix, uniqueKey, timestampKey, timestampFormat, sqlInstance, destination).toString(); PreparedStatement upsertStatement = null; upsertStatement = connection.prepareStatement(upsertQuery); upsertPreparedStatement = SQLQueryUtils.addJsonValues(upsertStatement, lastData, attrNativeTypes); upsertPreparedStatement.executeBatch(); connection.commit(); LOGGER.info("Finished transaction: \n" + upsertPreparedStatement + "\n Inserted ROWS: " + insertedRows.length + " " + upsertQuery); } catch (SQLTimeoutException e) { cygnusSQLRollback(connection); <START> throw new CygnusPersistenceError(sqlInstance.toUpperCase() + " " + e.getNextException() + " Data insertion error. Query: `" + connection, "SQLTimeoutException", e.getMessage()); <END> } catch (SQLException e) { cygnusSQLRollback(connection); throw new CygnusBadContextData(sqlInstance.toUpperCase() + " " + e.getNextException() + " Data insertion error. Query: `" + connection, "SQLException", e.getMessage()); } finally { closeStatement(insertPreparedStatement); closeStatement(upsertPreparedStatement); closeConnection(connection); } }</code><technical_language>upsertQuery printed, connection</technical_language>

Target:
public void upsertTransaction (LinkedHashMap<String, ArrayList<JsonElement>> aggregation, LinkedHashMap<String, ArrayList<JsonElement>> lastData, String destination, String tableName, String tableSuffix, String uniqueKey, String timestampKey, String timestampFormat, boolean attrNativeTypes) throws CygnusPersistenceError, CygnusBadContextData, CygnusRuntimeError, CygnusPersistenceError{ Connection connection = null; PreparedStatement upsertPreparedStatement = null; PreparedStatement insertPreparedStatement = null; int insertedRows[]; try { connection = driver.getConnection(destination); connection.setAutoCommit(false); String insertQuery = SQLQueryUtils.sqlInsertQuery(aggregation, tableName, sqlInstance, destination).toString(); PreparedStatement insertStatement = null; insertStatement = connection.prepareStatement(insertQuery); insertPreparedStatement = SQLQueryUtils.addJsonValues(insertStatement, aggregation, attrNativeTypes); insertedRows = insertPreparedStatement.executeBatch(); String upsertQuery = SQLQueryUtils.sqlUpsertQuery(aggregation, lastData, tableName, tableSuffix, uniqueKey, timestampKey, timestampFormat, sqlInstance, destination).toString(); PreparedStatement upsertStatement = null; upsertStatement = connection.prepareStatement(upsertQuery); upsertPreparedStatement = SQLQueryUtils.addJsonValues(upsertStatement, lastData, attrNativeTypes); upsertPreparedStatement.executeBatch(); connection.commit(); LOGGER.info("Finished transaction: \n" + upsertPreparedStatement + "\n Also, " + insertedRows.length + " where Inserted. THE LAS ONE WAS: " + " " + upsertQuery); } catch (SQLTimeoutException e) { cygnusSQLRollback(connection); throw new CygnusPersistenceError(sqlInstance.toUpperCase() + " " + e.getNextException() + " Data insertion error. Query: `" + connection, "SQLTimeoutException", e.getMessage()); } catch (SQLException e) { cygnusSQLRollback(connection); throw new CygnusBadContextData(sqlInstance.toUpperCase() + " " + e.getNextException() + " Data insertion error. Query: `" + connection, "SQLException", e.getMessage()); } finally { closeStatement(insertPreparedStatement); closeStatement(upsertPreparedStatement); closeConnection(connection); } }