seniorproj
Class DBConnect

java.lang.Object
  extended by seniorproj.DBConnect

public class DBConnect
extends java.lang.Object

Contains the lower level methods dealing with the database and constructing of sql queries.

Author:
Steven Weigand

Constructor Summary
DBConnect()
           
 
Method Summary
static boolean checkDup(java.lang.String[] names, int index, java.lang.String name)
          Checks to see if the given name already exists in array.
static boolean connection(java.lang.String username, java.lang.String password, java.lang.String db)
          Connects the user to the database.
static java.lang.String createWarehouse(java.lang.String name)
          Creates the create table code for the main warehouse table.
static java.lang.String execute(java.lang.String code)
          Runs given sql code on the database and provides positive and negative feedback.
static java.lang.String fillTable(java.lang.String tablename, Column[] columns)
          Creates the insert statements to fill a table.
static Column[] getColumns(java.lang.String tablename)
          Retrieves the columns for a given table name.
static java.lang.String[] getTableNames()
          Retrieves all of the tables available to the user from his/her account.
static java.lang.String starTable()
          Creates the insert statement for the main table of the data warehouse.
static java.lang.String tableCode(java.lang.String name)
          Creates table code for a given table.
static java.lang.String traverseFKey(DependentVar var)
          Creates the where clause for the sql by examining the foreign keys of attributes neighbors.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DBConnect

public DBConnect()
Method Detail

connection

public static boolean connection(java.lang.String username,
                                 java.lang.String password,
                                 java.lang.String db)
Connects the user to the database.

Parameters:
username - Student's username
password - Student's password
db - Student's chosen db
Returns:
boolean indicating if login was successful or not.

getTableNames

public static java.lang.String[] getTableNames()
Retrieves all of the tables available to the user from his/her account.

Returns:
Array containing available table names in the user's account.

getColumns

public static Column[] getColumns(java.lang.String tablename)
Retrieves the columns for a given table name.

Parameters:
tablename - Name of table to retrieve columns for
Returns:
Array containg all columns in given table

createWarehouse

public static java.lang.String createWarehouse(java.lang.String name)
Creates the create table code for the main warehouse table.

Parameters:
name - Name of the central warehouse table
Returns:
String containing the sql statement

tableCode

public static java.lang.String tableCode(java.lang.String name)
Creates table code for a given table. This is not called by the center of the star schema.

Parameters:
name - Name of table to create the statement for
Returns:
String containing sql statement

fillTable

public static java.lang.String fillTable(java.lang.String tablename,
                                         Column[] columns)
Creates the insert statements to fill a table.

Parameters:
tablename - Name of the table
columns - Columns of the given table
Returns:
The sql for the insert statements

checkDup

public static boolean checkDup(java.lang.String[] names,
                               int index,
                               java.lang.String name)
Checks to see if the given name already exists in array.

Parameters:
names - names of currently stored columns
index - number of stored columns to search
name - name of the column
Returns:
boolean indicating if a duplicate exists or not

traverseFKey

public static java.lang.String traverseFKey(DependentVar var)
Creates the where clause for the sql by examining the foreign keys of attributes neighbors.

Parameters:
var - Dependent variable to base traversal on
Returns:
Return String containing where clause

starTable

public static java.lang.String starTable()
Creates the insert statement for the main table of the data warehouse.

Returns:
String containing the sql code

execute

public static java.lang.String execute(java.lang.String code)
Runs given sql code on the database and provides positive and negative feedback.

Parameters:
code - sql to execute
Returns:
String containing database result of sql execution