org.sape.carbon.services.sql.connection
Class StandaloneConnectionFactory

java.lang.Object
  |
  +--org.sape.carbon.services.sql.connection.StandaloneConnectionFactory
All Implemented Interfaces:
Configurable, ConnectionFactory, FunctionalInterface

public class StandaloneConnectionFactory
extends Object
implements ConnectionFactory, Configurable

A Factory for JDBC Connections. Hides interaction with the JDBC driver. Maintains a reference to a JDBC Driver, plus connection info (userId, password, URL). Note that the Driver instance is discarded and recreated each time the component is configured. Copyright 2002 Sapient

Since:
carbon 1.0
Version:
$Revision: 1.13 $($Author: araman $ / $Date: 2003/07/29 08:01:30 $)
Author:
Chris Herron, March 2002
See Also:
StandaloneConnectionFactoryConfiguration

Field Summary
protected  Properties dbConnectionProperties
          The properties passed to the JDBC driver to obtain a connection.
protected  String dbUrl
          The JDBC connection URL for the database.
protected  Driver driver
          A reference to the database driver.
private  org.apache.commons.logging.Log log
          Provides a handle to Apache-commons logger
protected static String PASSWORD_KEY
          The environment key for the password to authenticate a database connection with.
protected static String USER_KEY
          The environment key for the username to authenticate a database connection with.
 
Constructor Summary
StandaloneConnectionFactory()
           
 
Method Summary
 void configure(ComponentConfiguration configuration)
          Configure the component.
 Connection getConnection()
          Uses the configured JDBC Driver and connection parameters to return a JDBC connection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

USER_KEY

protected static final String USER_KEY
The environment key for the username to authenticate a database connection with.

See Also:
Constant Field Values

PASSWORD_KEY

protected static final String PASSWORD_KEY
The environment key for the password to authenticate a database connection with.

See Also:
Constant Field Values

driver

protected Driver driver
A reference to the database driver. This gets reset after each call to configure(...).


dbUrl

protected String dbUrl
The JDBC connection URL for the database.


dbConnectionProperties

protected Properties dbConnectionProperties
The properties passed to the JDBC driver to obtain a connection. Uses the keys "user" and "password" for the user and password values. (Constants defined below).


log

private org.apache.commons.logging.Log log
Provides a handle to Apache-commons logger

Constructor Detail

StandaloneConnectionFactory

public StandaloneConnectionFactory()
Method Detail

getConnection

public Connection getConnection()
                         throws SQLException
Uses the configured JDBC Driver and connection parameters to return a JDBC connection.

Specified by:
getConnection in interface ConnectionFactory
Returns:
Connection specified by this factory
Throws:
SQLException - indicates an error creating the connection to the datasource

configure

public void configure(ComponentConfiguration configuration)
Configure the component. This is preceded and followed by the suspend and resume operations if they are available on the component.

Specified by:
configure in interface Configurable
Parameters:
configuration - A StandaloneConnectionFactoryConfiguration instance


Copyright 1999-2003 Sapient Corporation. All Rights Reserved.