gov.sns.tools.database
Class DatabaseAdaptor

java.lang.Object
  |
  +--gov.sns.tools.database.DatabaseAdaptor
Direct Known Subclasses:
OracleDatabaseAdaptor

public abstract class DatabaseAdaptor
extends java.lang.Object

DatabaseAdaptor provides a generic adaptor to wrap database specific code. For example, making a SQL array requires database specific code.


Constructor Summary
DatabaseAdaptor()
           
 
Method Summary
abstract  java.sql.Array getArray(java.lang.String type, java.sql.Connection connection, java.lang.Object array)
          Get an SQL Array given an SQL array type, connection and a primitive array
 java.sql.Connection getConnection(ConnectionDictionary dictionary)
          Get a new database connection
abstract  java.sql.Connection getConnection(java.lang.String urlSpec, java.lang.String user, java.lang.String password)
          Get a new database connection
static DatabaseAdaptor getInstance()
          Get a new database adaptor using the default database adaptor
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DatabaseAdaptor

public DatabaseAdaptor()
Method Detail

getArray

public abstract java.sql.Array getArray(java.lang.String type,
                                        java.sql.Connection connection,
                                        java.lang.Object array)
                                 throws DatabaseException
Get an SQL Array given an SQL array type, connection and a primitive array

Parameters:
type - An SQL array type identifying the type of array
connection - An SQL connection
array - The primitive Java array
Returns:
the SQL array which wraps the primitive array
Throws:
DatabaseException - if a database exception is thrown

getConnection

public abstract java.sql.Connection getConnection(java.lang.String urlSpec,
                                                  java.lang.String user,
                                                  java.lang.String password)
                                           throws DatabaseException
Get a new database connection

Parameters:
urlSpec - The URL to which to connect
user - The user loggin into the database
password - the user's password
Throws:
DatabaseException - if a database exception is thrown

getConnection

public java.sql.Connection getConnection(ConnectionDictionary dictionary)
                                  throws DatabaseException
Get a new database connection

Parameters:
dictionary - A connection dictionary
Throws:
DatabaseException - if a database exception is thrown

getInstance

public static DatabaseAdaptor getInstance()
Get a new database adaptor using the default database adaptor

Returns:
A new instance of the default database adaptor