org.enableit.db
Class ConnFactory

java.lang.Object
  |
  +--org.enableit.db.ConnFactory
Direct Known Subclasses:
ConnectionFactory

public class ConnFactory
extends java.lang.Object

Factory for database connections.

This is a functional replacement for the ConnectionFactory that has been deprecated as it contains a great deal of legacy (and not very clean) code.

Author:
TimSt

Constructor Summary
protected ConnFactory()
          Constructor, prevents public construction.
 
Method Summary
static java.sql.Connection getConnection(org.enableit.db.beans.Provider provider)
          Returns a connection to the database identified within the supplied provider.
static java.sql.Connection getConnection(java.lang.String name)
          Obtain connection for the named configuration.
protected static void registerDriver(java.lang.String driver)
          Register the named driver class with DriverManager.
protected static void registerDriverFromUrl(java.lang.String url)
          Attempt to decode the JDBC URL and register the driver if it is of known type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConnFactory

protected ConnFactory()
Constructor, prevents public construction.

Method Detail

getConnection

public static java.sql.Connection getConnection(org.enableit.db.beans.Provider provider)
                                         throws DBException
Returns a connection to the database identified within the supplied provider.

Parameters may be empty strings, but may not be null.

Parameters:
provider - Contains connection details.
Returns:
Connection
Throws:
DBException - in the event of a problem creating the connection

registerDriver

protected static void registerDriver(java.lang.String driver)
Register the named driver class with DriverManager.

Parameters:
driver - Name of driver class.

registerDriverFromUrl

protected static void registerDriverFromUrl(java.lang.String url)
Attempt to decode the JDBC URL and register the driver if it is of known type.

Parameters:
url - Database URL to connect to.

getConnection

public static java.sql.Connection getConnection(java.lang.String name)
                                         throws DBException
Obtain connection for the named configuration.

Implementation Note: The name will first be treated as a JDBC2 DataSource name to be looked up in the local naming context. If that fails the ConnectionFactory will fall back on its own configuration to attempt to obtain a connection.

Parameters:
name - Data source configuration name.
Returns:
Connection
Throws:
DBException - If the named configuration is not found.
See Also:
#getConnectionNames


Copyright © 1999-2004 enableIT.org. All Rights Reserved.