com.rhi.architecture.db
Class InitializingConnectionFactory

java.lang.Object
  extended bycom.rhi.architecture.db.InitializingConnectionFactory
All Implemented Interfaces:
org.apache.commons.dbcp.ConnectionFactory

public class InitializingConnectionFactory
extends java.lang.Object
implements org.apache.commons.dbcp.ConnectionFactory

Wrapper/Decorator Factory which allows you to run an arbitrary SQL statement after each connection is created. This can be useful for calling "use schema ?" or or any number of other connection intialization statements before passing the connection back to the client.

Version:
1.0
Author:
Pete McKinstry

Constructor Summary
InitializingConnectionFactory(org.apache.commons.dbcp.ConnectionFactory factory, java.lang.String sql)
          Constructor - the Connection factory you wish to supplement.
 
Method Summary
 java.sql.Connection createConnection()
          Create the connection using the provided connection factory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InitializingConnectionFactory

public InitializingConnectionFactory(org.apache.commons.dbcp.ConnectionFactory factory,
                                     java.lang.String sql)
Constructor - the Connection factory you wish to supplement. (can be any type), and the SQL which you wish to run after each conncection. If the SQL String is null, nothing is done & the connection is returned.

Parameters:
factory -
sql -
Method Detail

createConnection

public java.sql.Connection createConnection()
                                     throws java.sql.SQLException
Create the connection using the provided connection factory. After the connection is created, call the intialization statement to "prepare" the connection. Then return it. If a null or empty SQL string is passed, no statement is executed.

Specified by:
createConnection in interface org.apache.commons.dbcp.ConnectionFactory
Returns:
Connection
Throws:
java.sql.SQLException
Since:
1.0
See Also:
ConnectionFactory.createConnection()


Copyright © 2002-2004 Robert Half International. All Rights Reserved.