package danielcortes.xyz.data;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class SQLiteConnectionHolder implements ConnectionHolder {
  private String databaseURI;

  public SQLiteConnectionHolder() {
    this.databaseURI = Configuration.get("sqlite_database_uri");
  }

  public SQLiteConnectionHolder(String databaseURI){
    this.databaseURI = databaseURI;
  }

  @Override
  public Connection getConnection() throws SQLException {
    Connection con = null;

    try {
      Class.forName("org.sqlite.JDBC");
      con = DriverManager.getConnection(databaseURI);
    } catch (ClassNotFoundException e) {
      System.exit(133);
    }

    return con;
  }
}
