org.apache.avalon.excalibur.datasource
Class JdbcConnectionFactory

java.lang.Object
  extended by org.apache.avalon.framework.logger.AbstractLogEnabled
      extended by org.apache.avalon.excalibur.datasource.JdbcConnectionFactory
All Implemented Interfaces:
org.apache.avalon.excalibur.pool.ObjectFactory, org.apache.avalon.framework.logger.LogEnabled

public class JdbcConnectionFactory
extends org.apache.avalon.framework.logger.AbstractLogEnabled
implements org.apache.avalon.excalibur.pool.ObjectFactory

The Factory implementation for JdbcConnections.

Since:
4.0
Version:
CVS $Revision: 1.4 $ $Date: 2004/02/28 11:47:14 $
Author:
Avalon Development Team

Field Summary
private static java.lang.String DEFAULT_KEEPALIVE
           
private  boolean m_autoCommit
           
private  java.lang.Class m_class
           
private  java.lang.String m_connectionClass
           
private  java.lang.String m_dburl
           
private  java.sql.Connection m_firstConnection
           
private  java.lang.String m_keepAlive
           
private  int m_keepAliveAge
           
private  java.lang.String m_password
           
private  java.lang.String m_username
           
private static java.lang.String ORACLE_KEEPALIVE
           
 
Constructor Summary
JdbcConnectionFactory(java.lang.String url, java.lang.String username, java.lang.String password, boolean autoCommit, boolean oradb)
          Deprecated. Use the new constructor with the keepalive and connectionClass specified.
JdbcConnectionFactory(java.lang.String url, java.lang.String username, java.lang.String password, boolean autoCommit, boolean oradb, java.lang.String connectionClass)
          Deprecated. Use the new constructor with the keepalive and connectionClass specified.
JdbcConnectionFactory(java.lang.String url, java.lang.String username, java.lang.String password, boolean autoCommit, java.lang.String keepAlive, int keepAliveAge, java.lang.String connectionClass)
          Creates and configures a new JdbcConnectionFactory.
JdbcConnectionFactory(java.lang.String url, java.lang.String username, java.lang.String password, boolean autoCommit, java.lang.String keepAlive, java.lang.String connectionClass)
          Creates and configures a new JdbcConnectionFactory.
 
Method Summary
 void decommission(java.lang.Object object)
           
 java.lang.Class getCreatedClass()
           
private  java.sql.Connection getProxy(java.sql.Connection conn, java.lang.String keepAlive, int keepAliveAge)
           
private  void init()
           
 java.lang.Object newInstance()
           
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_dburl

private final java.lang.String m_dburl

m_username

private final java.lang.String m_username

m_password

private final java.lang.String m_password

m_autoCommit

private final boolean m_autoCommit

m_keepAlive

private final java.lang.String m_keepAlive

m_keepAliveAge

private final int m_keepAliveAge

m_connectionClass

private final java.lang.String m_connectionClass

m_class

private java.lang.Class m_class

DEFAULT_KEEPALIVE

private static final java.lang.String DEFAULT_KEEPALIVE
See Also:
Constant Field Values

ORACLE_KEEPALIVE

private static final java.lang.String ORACLE_KEEPALIVE
See Also:
Constant Field Values

m_firstConnection

private java.sql.Connection m_firstConnection
Constructor Detail

JdbcConnectionFactory

public JdbcConnectionFactory(java.lang.String url,
                             java.lang.String username,
                             java.lang.String password,
                             boolean autoCommit,
                             boolean oradb)
Deprecated. Use the new constructor with the keepalive and connectionClass specified.


JdbcConnectionFactory

public JdbcConnectionFactory(java.lang.String url,
                             java.lang.String username,
                             java.lang.String password,
                             boolean autoCommit,
                             boolean oradb,
                             java.lang.String connectionClass)
Deprecated. Use the new constructor with the keepalive and connectionClass specified.


JdbcConnectionFactory

public JdbcConnectionFactory(java.lang.String url,
                             java.lang.String username,
                             java.lang.String password,
                             boolean autoCommit,
                             java.lang.String keepAlive,
                             java.lang.String connectionClass)
Creates and configures a new JdbcConnectionFactory.

Parameters:
url - full JDBC database url.
username - username to use when connecting to the database.
password - password to use when connecting to the database.
autoCommit - true if connections to the database should operate with auto commit enabled.
keepAlive - a query which will be used to check the statis of a connection after it has been idle. A null value will cause the keep alive feature to be disabled.
connectionClass - class of connections created by the factory.

JdbcConnectionFactory

public JdbcConnectionFactory(java.lang.String url,
                             java.lang.String username,
                             java.lang.String password,
                             boolean autoCommit,
                             java.lang.String keepAlive,
                             int keepAliveAge,
                             java.lang.String connectionClass)
Creates and configures a new JdbcConnectionFactory.

Parameters:
url - full JDBC database url.
username - username to use when connecting to the database.
password - password to use when connecting to the database.
autoCommit - true if connections to the database should operate with auto commit enabled.
keepAlive - a query which will be used to check the statis of a connection after it has been idle. A null value will cause the keep alive feature to be disabled.
keepAliveAge - the maximum age in milliseconds since a connection was last used before it must be pinged using the keepAlive query. Ignored if keepAlive is null.
connectionClass - class of connections created by the factory.
Method Detail

init

private void init()
           throws java.lang.Exception
Throws:
java.lang.Exception

newInstance

public java.lang.Object newInstance()
                             throws java.lang.Exception
Specified by:
newInstance in interface org.apache.avalon.excalibur.pool.ObjectFactory
Throws:
java.lang.Exception

getCreatedClass

public java.lang.Class getCreatedClass()
Specified by:
getCreatedClass in interface org.apache.avalon.excalibur.pool.ObjectFactory

decommission

public void decommission(java.lang.Object object)
                  throws java.lang.Exception
Specified by:
decommission in interface org.apache.avalon.excalibur.pool.ObjectFactory
Throws:
java.lang.Exception

getProxy

private java.sql.Connection getProxy(java.sql.Connection conn,
                                     java.lang.String keepAlive,
                                     int keepAliveAge)