/*   Copyright 2014 BossLetsPlays(Matthew Rogers), TheJeterLP (Joey Peter)
 *
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 */
package de.thejeterlp.bukkit.bukkittools.database;

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

public class SQLite extends Database {
    
    private final File dbFile;

    /**
     * Creates a new instance for SQLite databases.
     * Statements are done by {@link de.thejeterlp.bukkit.bukkittools.database.SQLite#executeStatement(java.lang.String) }
     * @param dbFile Database file
     */
    public SQLite(File dbFile) {
        super("org.sqlite.JDBC");
        dbFile.getParentFile().mkdirs();
        this.dbFile = dbFile;
    }

    @Override
    public void reactivateConnection() throws SQLException {
        setConnection(DriverManager.getConnection("jdbc:sqlite://" + dbFile.getAbsolutePath()));
    }

}
