org.archiviststoolkit.util
Class DatabaseConnectionUtils

java.lang.Object
  extended by org.archiviststoolkit.util.DatabaseConnectionUtils

public class DatabaseConnectionUtils
extends java.lang.Object


Nested Class Summary
static class DatabaseConnectionUtils.DatabaseVersion
           
 
Field Summary
static java.lang.String CHECK_VERSION_FROM_MAIN
           
static java.lang.String CHECK_VERSION_FROM_UPGRADE
           
static java.lang.String CHECK_VERSION_FROM_UTILITIES
           
 
Constructor Summary
DatabaseConnectionUtils()
           
 
Method Summary
static java.lang.Boolean checkPermissions(java.lang.String databaseType)
           
static java.lang.Boolean checkVersion(java.lang.String calledFrom)
           
static DatabaseConnectionUtils.DatabaseVersion getDatabaseVersionInfo(java.sql.Connection conn)
           
static java.lang.String getErrorString()
           
static java.lang.String isDatabaseEmpty(java.lang.String databaseType, java.lang.String databaseUrl, java.lang.String username, java.lang.String password)
          Method to check to see if a database being initialized is empty
static java.util.HashMap loadDatabaseConnectionInformation()
          Method to read in saved connection information from a text file
static void saveDatabaseConnectionInformation(java.util.HashMap savedConnections)
          Method to save database connection information to a tab delimited text file in the user's home directory.
static void setErrorString(java.lang.String errorString)
           
static java.lang.Boolean testDbConnection()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CHECK_VERSION_FROM_MAIN

public static final java.lang.String CHECK_VERSION_FROM_MAIN
See Also:
Constant Field Values

CHECK_VERSION_FROM_UPGRADE

public static final java.lang.String CHECK_VERSION_FROM_UPGRADE
See Also:
Constant Field Values

CHECK_VERSION_FROM_UTILITIES

public static final java.lang.String CHECK_VERSION_FROM_UTILITIES
See Also:
Constant Field Values
Constructor Detail

DatabaseConnectionUtils

public DatabaseConnectionUtils()
Method Detail

testDbConnection

public static java.lang.Boolean testDbConnection()

checkVersion

public static java.lang.Boolean checkVersion(java.lang.String calledFrom)
                                      throws java.lang.ClassNotFoundException,
                                             java.sql.SQLException
Throws:
java.lang.ClassNotFoundException
java.sql.SQLException

checkPermissions

public static java.lang.Boolean checkPermissions(java.lang.String databaseType)
                                          throws java.lang.ClassNotFoundException
Throws:
java.lang.ClassNotFoundException

isDatabaseEmpty

public static java.lang.String isDatabaseEmpty(java.lang.String databaseType,
                                               java.lang.String databaseUrl,
                                               java.lang.String username,
                                               java.lang.String password)
                                        throws java.lang.ClassNotFoundException
Method to check to see if a database being initialized is empty

Parameters:
databaseType - The type of the database
Returns:
Null if the database is empty or String if it is not empty, or an error occured
Throws:
java.lang.ClassNotFoundException

getErrorString

public static java.lang.String getErrorString()

setErrorString

public static void setErrorString(java.lang.String errorString)

getDatabaseVersionInfo

public static DatabaseConnectionUtils.DatabaseVersion getDatabaseVersionInfo(java.sql.Connection conn)
                                                                      throws java.sql.SQLException
Throws:
java.sql.SQLException

loadDatabaseConnectionInformation

public static java.util.HashMap loadDatabaseConnectionInformation()
Method to read in saved connection information from a text file

Returns:
A hashmap containing any saved database connection objects

saveDatabaseConnectionInformation

public static void saveDatabaseConnectionInformation(java.util.HashMap savedConnections)
Method to save database connection information to a tab delimited text file in the user's home directory.

Parameters:
savedConnections - The HashMap containing saved database connection information