package main.java;

import main.java.ui.MainMenu;
import org.postgresql.ds.PGSimpleDataSource;

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

public class Main {
    public static void main(String[] args) {
        PGSimpleDataSource dataSource = new PGSimpleDataSource();

        dataSource.setServerName("db.dai.fmph.uniba.sk");
        dataSource.setPortNumber(5432);
        dataSource.setDatabaseName("playground");
        dataSource.setUser("pitak4@uniba.sk");
        dataSource.setPassword("rootheslo");

//        dataSource.setServerName("localhost");
//        dataSource.setPortNumber(5432);
//        dataSource.setDatabaseName("kino"); //nazov vasho server
//        dataSource.setUser("postgres"); //username
//        dataSource.setPassword("a"); //password z pgAdmin4

        try (Connection connection = dataSource.getConnection()){
            DbConnection.setConnection(connection);

            //run menu
            MainMenu menu = new MainMenu();
            menu.run();
        } catch (SQLException | IOException e){
            e.printStackTrace();
        } finally {
            DbConnection.clear();
        }
    }
}
