All Downloads are FREE. Search and download functionalities are using the official Maven repository.

me.deecaad.core.database.SQLite Maven / Gradle / Ivy

package me.deecaad.core.database;

import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;

import java.io.File;
import java.io.IOException;
import java.sql.SQLException;

public class SQLite extends HikariBased {

    public SQLite(String absolutePath) throws IOException, SQLException {
        super(DatabaseType.SQLITE);

        if (!absolutePath.endsWith(".db"))
            throw new IllegalArgumentException("Database has to end in .db " + "(" + absolutePath + ")");

        File db = new File(absolutePath);
        if (!db.exists()) {
            db.getParentFile().mkdirs();
            db.createNewFile();
        }

        HikariConfig config = new HikariConfig();

        config.setPoolName("WMSQLite");
        config.setDriverClassName("org.sqlite.JDBC");
        config.setJdbcUrl("jdbc:sqlite:" + absolutePath);

        dataSource = new HikariDataSource(config);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy