<commit_before>package io.github.aquerr.eaglefactions.storage.sql.sqlite;

import io.github.aquerr.eaglefactions.api.EagleFactions;
import io.github.aquerr.eaglefactions.storage.StorageType;
import io.github.aquerr.eaglefactions.storage.sql.SQLAbstractProvider;
import org.spongepowered.api.Sponge;
import org.spongepowered.api.sql.SqlManager;

import javax.sql.DataSource;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;

public class SqliteProvider extends SQLAbstractProvider
{
    private static SqliteProvider INSTANCE = null;

    private final DataSource dataSource;

    public static SqliteProvider getInstance(final EagleFactions eagleFactions)
    {
        if (INSTANCE == null)
        {
            try
            {
                INSTANCE = new SqliteProvider(eagleFactions);
                return INSTANCE;
            }
            catch(final SQLException e)
            {
                e.printStackTrace();
                return null;
            }
        }
        else return INSTANCE;
    }

    private SqliteProvider(final EagleFactions eagleFactions) throws SQLException
    {
        super(eagleFactions);
        final Path databaseDir = eagleFactions.getConfigDir().resolve("data/sqlite");
        try
        {
            Files.createDirectories(databaseDir);
        }
        catch (IOException exception)
        {
            exception.printStackTrace();
            throw new RuntimeException(exception);
        }
        final Path databasePath = databaseDir.resolve(getDatabaseName() + ".db");
        final SqlManager sqlManager = Sponge.sqlManager();
        this.dataSource = sqlManager.dataSource("jdbc:sqlite://" + super.getUsername() + ":" + super.getPassword() + "@" + databasePath);
        final Connection connection = getConnection();
        connection.close();
    }

    public Connection getConnection() throws SQLException
    {
        Connection connection = this.dataSource.getConnection();
        Statement statement = connection.createStatement();
        statement.execute("PRAGMA foreign_keys = ON;");
        statement.close();
        return connection;
    }

    @Override
    public StorageType getStorageType()
    {
        return StorageType.SQLITE;
    }
}<commit_msg>Fix connecting to sqlite database<commit_after>package io.github.aquerr.eaglefactions.storage.sql.sqlite;

import io.github.aquerr.eaglefactions.api.EagleFactions;
import io.github.aquerr.eaglefactions.storage.StorageType;
import io.github.aquerr.eaglefactions.storage.sql.SQLAbstractProvider;
import org.spongepowered.api.Sponge;
import org.spongepowered.api.sql.SqlManager;

import javax.sql.DataSource;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;

public class SqliteProvider extends SQLAbstractProvider
{
    private static SqliteProvider INSTANCE = null;

    private final DataSource dataSource;

    public static SqliteProvider getInstance(final EagleFactions eagleFactions)
    {
        if (INSTANCE == null)
        {
            try
            {
                INSTANCE = new SqliteProvider(eagleFactions);
                return INSTANCE;
            }
            catch(final SQLException e)
            {
                e.printStackTrace();
                return null;
            }
        }
        else return INSTANCE;
    }

    private SqliteProvider(final EagleFactions eagleFactions) throws SQLException
    {
        super(eagleFactions);
        final Path databaseDir = eagleFactions.getConfigDir().resolve("data/sqlite");
        try
        {
            Files.createDirectories(databaseDir);
        }
        catch (IOException exception)
        {
            exception.printStackTrace();
            throw new RuntimeException(exception);
        }
        final Path databasePath = databaseDir.resolve(getDatabaseName() + ".db");
        final SqlManager sqlManager = Sponge.sqlManager();
        this.dataSource = sqlManager.dataSource("jdbc:sqlite:" + super.getUsername() + ":" + super.getPassword() + "@" + databasePath);
        final Connection connection = getConnection();
        connection.close();
    }

    public Connection getConnection() throws SQLException
    {
        Connection connection = this.dataSource.getConnection();
        Statement statement = connection.createStatement();
        statement.execute("PRAGMA foreign_keys = ON;");
        statement.close();
        return connection;
    }

    @Override
    public StorageType getStorageType()
    {
        return StorageType.SQLITE;
    }
}
{'fraction_non_alphanumeric': 0.09052631578947369, 'fraction_numerical': 0.0, 'mean_word_length': 2.6184310738766183, 'pattern_counts': {'":': 2, '<': 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': '262902', 'n_tokens_mistral': 1261, 'n_tokens_neox': 1220, 'n_words': 256}