class DeleteSelectedRows extends SwingWorkerPM {

    @Override
    protected Object doInBackground() throws SQLException {
        try(Connection connection = dataSource.getConnection()) {
            boolean isH2 = JDBCUtilities.isH2DataBase(connection.getMetaData());
            int columnId = JDBCUtilities.getIntegerPrimaryKey(connection, tableName);
            if(columnId > 0) {
                String pkColumnName = JDBCUtilities.getFieldName(connection.getMetaData(), tableName, columnId);
                // A deletion batch is an ordered set of pk values to remove (a complete serial of integer without holes)
                List<Long> deletionBatch = rowPkToDelete.getValueRanges();
                ProgressMonitor pmBatch = getProgressMonitor().startTask(deletionBatch.size() / 2);
                try(PreparedStatement st = connection.prepareStatement(
                        String.format("DELETE FROM %s WHERE %s >= ? AND %s <= ?",
                                TableLocation.parse(tableName).toString(isH2),pkColumnName, pkColumnName))) {
                    for (int idDelBatch = 0; idDelBatch < deletionBatch.size() - 1; idDelBatch += 2) {
                        long startBatch = deletionBatch.get(idDelBatch);
                        long endBatch = deletionBatch.get(idDelBatch + 1);
                        st.setLong(1, startBatch);
                        st.setLong(2, endBatch);
                        st.execute();
                        pmBatch.endTask();
                    }
                }
            }
        }
        return null;
    }

    public  DeleteSelectedRows(SortedSet<Long> rowPkToDelete, String tableName, DataSource dataSource);

}