Skip to content
Snippets Groups Projects
Model.java 953 B
package com.example.schedulerapp;

import java.sql.*;

public class Model {
    protected Staff staff;
    protected Schedule schedule;
    private Connection dbConnection;

    public Model(){
        connectDataBase();
        this.staff = new Staff(dbConnection);
        this.schedule = new Schedule(dbConnection);
    }

    protected String connectDataBase(){
        try {
            dbConnection = DriverManager.getConnection("jdbc:mysql://localhost:3306/ScheduleApp", "root", "password");
        } catch (Exception e) {
            System.out.println(e.fillInStackTrace());
            return "Couldn't connect to database.";
        }
        return "Successfully connected to database.";
    }

    public static void main(String[] args) {
        Model model = new Model();

        /* Testing stuff that should be cleaned up for the alpha
        String s = model.staff.getEmployees();
        System.out.println();

         */
    }

}