Skip to content
Snippets Groups Projects
Commit 205dba5a authored by Rafi Zereselasie (raz070)'s avatar Rafi Zereselasie (raz070)
Browse files

Refactored RafisWeirdClass to DataBaseQuery and added comments.

parent 4a4b3af7
No related branches found
No related tags found
1 merge request!6Changed update implementation for employees so rather than sending the whole...
......@@ -2,18 +2,40 @@ package com.example.schedulerapp;
import java.sql.*;
public class RafisWeirdClass {
/*
Name: DataBaseQuery
Description: Makes the connection to the database, and sends the connection to the Staff and Schedule after
initializing them.
*/
public class DataBaseQuery {
protected Staff staff;
protected Schedule schedule;
private Connection dbConnection;
public RafisWeirdClass(String dbURL, String dbUser, String dbPass){
/*
Name: DataBaseQuery
Parameters:
String dbURL: The URL of the database
String dbUser: The username of the database.
String dbPass: The password of the database.
Description: Calls connectDataBase and initializes the Staff and Schedule.
Return: DataBaseQuery
*/
public DataBaseQuery(String dbURL, String dbUser, String dbPass){
connectDataBase(dbURL, dbUser, dbPass);
this.staff = new Staff(dbConnection);
this.schedule = new Schedule(dbConnection);
}
/*
Name: connectDataBase
Parameters:
String dbURL: The URL of the database
String dbUser: The username of the database.
String dbPass: The password of the database.
Description: Establishes the connection to the database.
Return: void
*/
protected void connectDataBase(String dbURL, String dbUser, String dbPass){
try {
dbConnection = DriverManager.getConnection(dbURL, dbUser, dbPass);
......@@ -24,6 +46,4 @@ public class RafisWeirdClass {
System.out.println("Successfully connected to the database");
}
public static void main(String[] args) {
}
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment