scheduler.db
Class SQLDB

java.lang.Object
  extended by scheduler.db.SQLDB

public class SQLDB
extends java.lang.Object

This class provides for direct access to a MySQL database. Though it a user can connect to a database, get different tables related to the scheduler, and insert SQL statements to be run in the database.

Author:
Cedric Wienold, Jan Lorenz Soliman, and Leland Garofalo

Field Summary
private  java.sql.Connection conn
          The connection
private  CourseDB courseDB
          The course database.
private  InstructorDB instructorDB
          The instructor database.
private  LocationDB locationDB
          The location databse.
private  PreferencesDB preferencesDB
          The preferences database
 
Constructor Summary
SQLDB()
          This constructor will create the SQLDB object.
 
Method Summary
 void close()
          The close() method closes a connection to the database.
 CourseDB getCourseDB()
          Returns the course database.
 InstructorDB getInstructorDB()
          Returns the instructor database.
 Course getLab(java.util.ArrayList<Course> arrList, int lab)
          Returns the instructor database.
 LocationDB getLocationDB()
          Returns the location database.
 PreferencesDB getPreferencesDB()
          Returns the preferences database.
 void insertPrefStmt(java.lang.String table, java.lang.String val)
          The insertPrefStmt runs a SQL insert command.
 void insertStmt(java.lang.String table, java.lang.String val)
          The insertStmt runs a SQL insert command.
 void open()
          The open() method opens a connection to the database.
 void open(java.lang.String url)
          This open() method will connect to a given database.
 void removePrefStmt(java.lang.String table, java.lang.String whereClause)
          The removePrefStmt method runs an SQL delete command on the preferences table.
 void removeStmt(java.lang.String table, java.lang.String whereClause)
          The removeStmt method runs an SQL delete command.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

instructorDB

private InstructorDB instructorDB
The instructor database.


courseDB

private CourseDB courseDB
The course database.


locationDB

private LocationDB locationDB
The location databse.


preferencesDB

private PreferencesDB preferencesDB
The preferences database


conn

private java.sql.Connection conn
The connection

Constructor Detail

SQLDB

public SQLDB()
This constructor will create the SQLDB object.

Method Detail

getLocationDB

public LocationDB getLocationDB()
Returns the location database.

Returns:
the location database.

getInstructorDB

public InstructorDB getInstructorDB()
Returns the instructor database.

Returns:
the instructor database.

getLab

public Course getLab(java.util.ArrayList<Course> arrList,
                     int lab)
Returns the instructor database.

Parameters:
arrList - An arraylist of courses
lab - An integer representing a lab's id
Returns:
the instructor database.

getCourseDB

public CourseDB getCourseDB()
Returns the course database.

Returns:
the course database.

getPreferencesDB

public PreferencesDB getPreferencesDB()
Returns the preferences database.

Returns:
the preferences database.
 // ** Pre and Post conditions ** //

 Pre:

 // SQL conn must not be Null
 conn != nil

 Post:

 // PreferencesDB can not be Null
 pdb != nil
 

 

open

public void open()
The open() method opens a connection to the database.


open

public void open(java.lang.String url)
This open() method will connect to a given database.

Parameters:
url - mysql url given in the format such as "mysql://cedders.homelinux.net/jseall".

close

public void close()
The close() method closes a connection to the database.


insertStmt

public void insertStmt(java.lang.String table,
                       java.lang.String val)
The insertStmt runs a SQL insert command.

Parameters:
table - A string representing the table that data will be added to.
val - A string representing the data to add.

insertPrefStmt

public void insertPrefStmt(java.lang.String table,
                           java.lang.String val)
The insertPrefStmt runs a SQL insert command.

Parameters:
table - A string representing the table that data will be added to
val - A string representing the data to add.
 // ** Pre and Post conditions ** //

 Pre:

 // table can not be Null
 table != nil

 &&

 // val can not be Null
 val != nil

 Post:

 // Preference is added to SQLDB
 
 table.contains(val)
 

 

removePrefStmt

public void removePrefStmt(java.lang.String table,
                           java.lang.String whereClause)
The removePrefStmt method runs an SQL delete command on the preferences table.

Parameters:
table - A string representing the table that data will be removed
whereClause - A string representing the data to remove.

removeStmt

public void removeStmt(java.lang.String table,
                       java.lang.String whereClause)
The removeStmt method runs an SQL delete command.

Parameters:
table - A string representing the table that data will be removed.
whereClause - A string representing the data to remove.