<commit_before>/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

package net.kockert.access.export;

import com.beust.jcommander.JCommander;
import com.healthmarketscience.jackcess.Database;
import com.healthmarketscience.jackcess.DatabaseBuilder;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class Main {

    private static final int EXIT_STATUS_INVALID_USAGE = 1;
    private static final int EXIT_STATUS_SOURCE_DOES_NOT_EXIST = 2;
    private static final int EXIT_STATUS_TARGET_DOES_ALREADY_EXIST = 3;
    private static final int EXIT_STATUS_ERROR_OPENING_SOURCE = 4;
    private static final int EXIT_STATUS_ERROR_OPENING_TARGET = 5;

    public static void main(String[] args) {
        CommandLineParameters clp = new CommandLineParameters();
        JCommander jCommander = new JCommander(clp);
        jCommander.parse(args);

        if (clp.helpRequested() || clp.insufficientParameters()) {
            jCommander.usage();
            System.exit(EXIT_STATUS_INVALID_USAGE);
        }

        try {
            Path sourceFile = getSourceFile(clp);
            Path targetFile = getTargetFile(clp);
            Database database = openSourceDatabase(sourceFile.toFile());
            Connection jdbcConnection = openTargetDatabase(targetFile);
            Exporter exporter = new Exporter(database, clp.getTablesToExport());
            exporter.export(jdbcConnection);
        } catch (SystemExitException e) {
            System.err.println(e.getMessage());<commit_msg>Make sure that resources are closed<commit_after>/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

package net.kockert.access.export;

import com.beust.jcommander.JCommander;
import com.healthmarketscience.jackcess.Database;
import com.healthmarketscience.jackcess.DatabaseBuilder;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class Main {

    private static final int EXIT_STATUS_INVALID_USAGE = 1;
    private static final int EXIT_STATUS_SOURCE_DOES_NOT_EXIST = 2;
    private static final int EXIT_STATUS_TARGET_DOES_ALREADY_EXIST = 3;
    private static final int EXIT_STATUS_ERROR_OPENING_SOURCE = 4;
    private static final int EXIT_STATUS_ERROR_OPENING_TARGET = 5;

    public static void main(String[] args) {
        CommandLineParameters clp = new CommandLineParameters();
        JCommander jCommander = new JCommander(clp);
        jCommander.parse(args);

        if (clp.helpRequested() || clp.insufficientParameters()) {
            jCommander.usage();
            System.exit(EXIT_STATUS_INVALID_USAGE);
        }

        try {
            Path sourceFile = getSourceFile(clp);
            Path targetFile = getTargetFile(clp);
            try (Database database = openSourceDatabase(sourceFile.toFile());
                 Connection jdbcConnection = openTargetDatabase(targetFile)) {
                Exporter exporter = new Exporter(database, clp.getTablesToExport());
                exporter.export(jdbcConnection);
            }
        } catch (SystemExitException e) {
            System.err.println(e.getMessage());
{'fraction_non_alphanumeric': 0.08598382749326146, 'fraction_numerical': 0.004851752021563342, 'mean_word_length': 3.3556338028169015, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4548758', 'n_tokens_mistral': 1078, 'n_tokens_neox': 1053, 'n_words': 273}