com.finalist.jaggenerator
Class DatabaseUtils

java.lang.Object
  extended bycom.finalist.jaggenerator.DatabaseUtils

public class DatabaseUtils
extends java.lang.Object

This class is a refactoring mid-step. The original code contained duplicate methods for database access in different classes - I've rehoused them here.

Author:
Michael O'Connor, Rudie Ekkelenkamp - Finalist IT Group

Field Summary
(package private) static org.apache.commons.logging.Log log
           
 
Constructor Summary
DatabaseUtils()
           
 
Method Summary
static void clearCache()
          This needs to be called when databases are switched.
static void clearColumnsCacheForTable(java.lang.String tableName)
          Forces an update of a particular table's columns the next time they are required.
static java.util.ArrayList getColumns(java.lang.String tablename)
          Gets all columns in the specified table, setting up a database connection if one isn't already available.
static java.util.ArrayList getColumns(java.lang.String tablename, boolean forceConnection)
          Gets all columns in the specified table.
static java.util.List getForeignKeys(java.lang.String tablename)
          Gets information about any foreign keys that are imported into the specified table.
static java.util.ArrayList getPrimaryKeys(java.lang.String tablename)
          A list with Strings of all primary key fields.
static java.util.ArrayList getTables()
          Grabs the list of tables from the database.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

static org.apache.commons.logging.Log log
Constructor Detail

DatabaseUtils

public DatabaseUtils()
Method Detail

getColumns

public static java.util.ArrayList getColumns(java.lang.String tablename)
Gets all columns in the specified table, setting up a database connection if one isn't already available.

Parameters:
tablename - the name of the table.
Returns:
an ArrayList of Column objects for all columns in the specified table, or null if the table/column doesn't exist.

getColumns

public static java.util.ArrayList getColumns(java.lang.String tablename,
                                             boolean forceConnection)
Gets all columns in the specified table.

Parameters:
tablename - the name of the table.
forceConnection - set to true if this method should force a database connect, if not already connected.
Returns:
an ArrayList of Column objects for all columns in the specified table; or null if the table/column doesn't exist, or if no database connection was available and forceConnection was set to false.

getForeignKeys

public static java.util.List getForeignKeys(java.lang.String tablename)
Gets information about any foreign keys that are imported into the specified table.

Parameters:
tablename -
Returns:
a List of ForeignKey objects, never null..

getPrimaryKeys

public static java.util.ArrayList getPrimaryKeys(java.lang.String tablename)
A list with Strings of all primary key fields.

Parameters:
tablename -
Returns:
an ArrayList of primary key column names for the specified table, never null.

getTables

public static java.util.ArrayList getTables()
Grabs the list of tables from the database.

Returns:
a List of table names (String), never null.

clearCache

public static void clearCache()
This needs to be called when databases are switched.


clearColumnsCacheForTable

public static void clearColumnsCacheForTable(java.lang.String tableName)
Forces an update of a particular table's columns the next time they are required.

Parameters:
tableName -


Copyright © 2003-2005 SourceForge. All Rights Reserved.