org.radrails.db.core
Class DatabaseConnector

java.lang.Object
  extended byorg.radrails.db.core.DatabaseConnector

public class DatabaseConnector
extends java.lang.Object

Class provides a method for getting a connection to a database.

Version:
0.3.0
Author:
mbaumbach

Method Summary
 java.sql.Connection getConnection(java.lang.Class driver, java.lang.String url, java.lang.String username, java.lang.String password)
          Gets a connection to a database.
static DatabaseConnector getInstance()
          Gets an instance of this class.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static DatabaseConnector getInstance()
Gets an instance of this class.

Returns:
A DatabaseConnector object.

getConnection

public java.sql.Connection getConnection(java.lang.Class driver,
                                         java.lang.String url,
                                         java.lang.String username,
                                         java.lang.String password)
                                  throws java.sql.SQLException,
                                         java.lang.InstantiationException,
                                         java.lang.IllegalAccessException
Gets a connection to a database.

Parameters:
driver - The driver class to use.
url - The URL to use to connect to the database.
username - The username to connect with.
password - The password to connect with.
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.