org.radrails.db.core
Class DatabaseConnection

java.lang.Object
  extended byorg.radrails.db.core.DatabaseConnection
Direct Known Subclasses:
IBMDB2DatabaseConnection, MySQLDatabaseConnection, OracleDatabaseConnection, PostgreSQLDatabaseConnection, SQLiteDatabaseConnection, SQLServerDatabaseConnection

public abstract class DatabaseConnection
extends java.lang.Object

Attempts to connect to a database.

Version:
0.3.0
Author:
mbaumbach

Constructor Summary
DatabaseConnection()
           
 
Method Summary
abstract  java.sql.Connection connect(DatabaseDescriptor descriptor)
          Gets a connection to a database.
abstract  java.lang.String getDefaultPort()
          Gets the default port for the specified database connection.
 boolean testConnect(DatabaseDescriptor descriptor)
          Tests if able to get a connection to a database.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DatabaseConnection

public DatabaseConnection()
Method Detail

testConnect

public boolean testConnect(DatabaseDescriptor descriptor)
Tests if able to get a connection to a database.

Parameters:
descriptor - The DatabaseDescriptor to use.
Returns:
true if a connection could be established, false otherwise.

connect

public abstract java.sql.Connection connect(DatabaseDescriptor descriptor)
                                     throws java.sql.SQLException,
                                            java.lang.InstantiationException,
                                            java.lang.IllegalAccessException
Gets a connection to a database.

Parameters:
descriptor - The DatabaseDescriptor to obtain information from.
Returns:
A java.sql.Connection to the database.
Throws:
java.sql.SQLException - If an error occurs while connecting to the database
java.lang.IllegalAccessException - If an error occurs while getting the driver class.
java.lang.InstantiationException - If the driver class cannot be instantiated.

getDefaultPort

public abstract java.lang.String getDefaultPort()
Gets the default port for the specified database connection.

Returns:
The default port, or null if no default is known.