edu.upenn.crimson.io
Class SQL

java.lang.Object
  extended by edu.upenn.crimson.io.SQL

public class SQL
extends java.lang.Object

Most SQL commands are contained here, to facilitate portability to different databases. This object does not do anything other than return SQL code. The running of the code and processing of the output is done by the calling methods.

Version:
$Id: SQL.java,v 1.20 2009/07/16 16:19:52 fisher Exp $

Field Summary
private static int dbType
          This is a name of the database: -1 = none.
private static java.lang.String[] dbTypes
          This is the list of databases we can use.
 
Constructor Summary
SQL()
           
 
Method Summary
static java.lang.String createTable(java.lang.String table)
          This method will create all of the necessary tables.
static java.lang.String dbDriver()
           
static java.lang.String dbURL()
           
static java.lang.String getDate()
          This will return the database date, as is used to test database connectivity.
static java.lang.String getDBType()
          Get the type of database (oracle or mysql).
static java.lang.String[] getDBTypes()
           
static int getDBTypeValue()
          Get the index value of the type of database.
static boolean isMySQL()
           
static boolean isOracle()
           
static boolean setDBType(java.lang.String type)
          Set the type of database (oracle or mysql).
static java.lang.String tableExists(java.lang.String table)
          This code will return the table name, if the table exists in the database.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dbTypes

private static final java.lang.String[] dbTypes
This is the list of databases we can use.


dbType

private static int dbType
This is a name of the database: -1 = none. By using an int to store the type we simplify tests for the type.

Constructor Detail

SQL

public SQL()
Method Detail

getDBTypes

public static java.lang.String[] getDBTypes()

getDBType

public static java.lang.String getDBType()
Get the type of database (oracle or mysql).


setDBType

public static boolean setDBType(java.lang.String type)
Set the type of database (oracle or mysql). This will return false if "type" is not a valid database type or is empty. If successful, this will update the default dbType.


getDBTypeValue

public static int getDBTypeValue()
Get the index value of the type of database. This value can be used to get the database type from dbTypes[].


isOracle

public static boolean isOracle()

isMySQL

public static boolean isMySQL()

dbDriver

public static java.lang.String dbDriver()

dbURL

public static java.lang.String dbURL()

getDate

public static java.lang.String getDate()
This will return the database date, as is used to test database connectivity.


tableExists

public static java.lang.String tableExists(java.lang.String table)
This code will return the table name, if the table exists in the database.


createTable

public static java.lang.String createTable(java.lang.String table)
This method will create all of the necessary tables.




Copyright 2006 Stephen Fisher, Susan Davidson, and Junhyong Kim, University of Pennsylvania.