Model.java 1023 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();
model.schedule.addShift(3, "2022-03-10", 1200, 2100, "shift");
/* Testing stuff that should be cleaned up for the alpha
String s = model.staff.getEmployees();
System.out.println();
*/
}
}