com.isti.util.database
Class AbstractDatabase

java.lang.Object
  extended by com.isti.util.database.AbstractDatabase
Direct Known Subclasses:
BasicDatabase

public abstract class AbstractDatabase
extends java.lang.Object


Field Summary
protected static java.lang.String EMPTY_TEXT
           
 
Constructor Summary
AbstractDatabase(ConnectionJDBC dbConn)
          Creates a connection to a basic database.
 
Method Summary
 void closeDatabaseConnection()
          Closes the database connection
 void executeQuery(java.lang.String sql)
          Executes an SQL statement that returns a single ResultSet object.
abstract  java.lang.String[] getColumnNames()
          Gets the column names to use in query
 java.util.List getColumnObjects()
          Gets a list of the column objects.
abstract  int getColumnOrderNumcolumns()
          Gets the number of columns to use for ordering
 java.lang.String getColumnPrefix()
          Gets the column prefix
 ConnectionJDBC getDatabaseConnection()
          Gets the database connection
 QueryJDBC getDatabaseQuery()
          Gets the database query
 java.text.SimpleDateFormat getDateFormatter()
          Gets the date formatter.
 java.text.SimpleDateFormat getDateFormatter(boolean shortFlag)
          Gets the date formatter.
abstract  java.lang.String getFromClause(java.lang.String text)
          Gets the from clause
 java.util.Map getMap(int index)
          Gets the data map for the specified index.
abstract  java.lang.String getOrderByClause(java.lang.String text)
          Gets the order by clause
abstract  java.lang.String getSelectClause(java.lang.String text)
          Gets the select clause
abstract  java.lang.String getString(int index)
          Gets a string representation of a database element.
abstract  java.lang.String getTableName()
          Gets the table name.
abstract  java.lang.String getTablePrefix()
          Gets the table prefix
 java.text.SimpleDateFormat getTimeFormatter()
          Gets the time formatter.
abstract  java.lang.String getTitle(int index)
          Gets a title string representation of a database element.
 void setDatabaseQuery(QueryJDBC dbQuery)
          Save the database query.
 void setDateFormatter(java.text.SimpleDateFormat dateFormatterObj)
          Sets the date formatter.
 void setTimeFormatter(java.text.SimpleDateFormat timeFormatterObj)
          Sets the time formatter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY_TEXT

protected static final java.lang.String EMPTY_TEXT
See Also:
Constant Field Values
Constructor Detail

AbstractDatabase

public AbstractDatabase(ConnectionJDBC dbConn)
Creates a connection to a basic database.

Parameters:
dbConn - database connection
Method Detail

getDatabaseConnection

public ConnectionJDBC getDatabaseConnection()
Gets the database connection

Returns:
the database connection

getDatabaseQuery

public QueryJDBC getDatabaseQuery()
Gets the database query

Returns:
the database query

setDatabaseQuery

public void setDatabaseQuery(QueryJDBC dbQuery)
Save the database query.

Parameters:
dbQuery - database query

getTableName

public abstract java.lang.String getTableName()
Gets the table name.

Returns:
the table name.

getTablePrefix

public abstract java.lang.String getTablePrefix()
Gets the table prefix

Returns:
the table prefix

getColumnNames

public abstract java.lang.String[] getColumnNames()
Gets the column names to use in query

Returns:
the column names to use in query or empty for all

getColumnOrderNumcolumns

public abstract int getColumnOrderNumcolumns()
Gets the number of columns to use for ordering

Returns:
the number of columns to use for ordering

getColumnPrefix

public java.lang.String getColumnPrefix()
Gets the column prefix

Returns:
the column prefix

getDateFormatter

public java.text.SimpleDateFormat getDateFormatter()
Gets the date formatter.

Returns:
the date formatter object.

getDateFormatter

public java.text.SimpleDateFormat getDateFormatter(boolean shortFlag)
Gets the date formatter.

Parameters:
shortFlag - true for short date format
Returns:
the date formatter object.

getTimeFormatter

public java.text.SimpleDateFormat getTimeFormatter()
Gets the time formatter.

Returns:
the time formatter object.

setDateFormatter

public void setDateFormatter(java.text.SimpleDateFormat dateFormatterObj)
Sets the date formatter.

Parameters:
dateFormatterObj - the date formatter object.

setTimeFormatter

public void setTimeFormatter(java.text.SimpleDateFormat timeFormatterObj)
Sets the time formatter.

Parameters:
timeFormatterObj - the time formatter object.

getSelectClause

public abstract java.lang.String getSelectClause(java.lang.String text)
Gets the select clause

Parameters:
text - select text
Returns:
the select clause

getFromClause

public abstract java.lang.String getFromClause(java.lang.String text)
Gets the from clause

Parameters:
text - from text
Returns:
the from clause

getOrderByClause

public abstract java.lang.String getOrderByClause(java.lang.String text)
Gets the order by clause

Parameters:
text - order by text
Returns:
the order by clause

executeQuery

public void executeQuery(java.lang.String sql)
                  throws java.lang.ClassNotFoundException,
                         java.lang.InstantiationException,
                         java.lang.IllegalAccessException,
                         java.sql.SQLException
Executes an SQL statement that returns a single ResultSet object.

Parameters:
sql - typically this is a static SQL SELECT statement
Throws:
java.lang.ClassNotFoundException - if the driver's class could not be found.
java.lang.InstantiationException - if the driver could not be instantiated.
java.lang.IllegalAccessException - if the driver's class or initializer is not accessible.
java.sql.SQLException - if a database access error occurs.

getColumnObjects

public java.util.List getColumnObjects()
Gets a list of the column objects. The list contains Map objects with the column name for the key.

Returns:
list of column objects.

getMap

public java.util.Map getMap(int index)
Gets the data map for the specified index.

Parameters:
index - database index
Returns:
data map

closeDatabaseConnection

public void closeDatabaseConnection()
Closes the database connection


getString

public abstract java.lang.String getString(int index)
Gets a string representation of a database element.

Parameters:
index - database element index
Returns:
a string representation of a database element.

getTitle

public abstract java.lang.String getTitle(int index)
Gets a title string representation of a database element.

Parameters:
index - database element index
Returns:
a title string representation of a database element.