nl.knowledgeplaza.util.pool
Class JdbcConnectionPoolFactory

java.lang.Object
  extended by nl.knowledgeplaza.util.pool.JdbcConnectionPoolFactory
All Implemented Interfaces:
PoolableObjectFactory

public class JdbcConnectionPoolFactory
extends Object
implements PoolableObjectFactory

Generates JDBC Connections from a configuration properties. The connections have default autocommit = false, readonly = false. Usage in a servlet: ObjectPool lConnectionObjectPool = null; Connection lConnection = null; try { lConnectionObjectPool = JdbcConnectionPoolFactory.getConnectionPool(request, "WPS", null); // poolname = "WPS", applicationname (for configuration properties) = null lConnection = (Connection)lConnectionObjectPool.borrowObject(); ... } finally { if (lConnection != null) lConnectionObjectPool.returnObject(lConnection); if (lConnectionObjectPool != null) lConnectionObjectPool.close(); } This will create or retrieve a pool (stored in getServletContext aka application context). It is custom to have some kind of storage for created pools, a regular application could use a static Map based on the poolname. org.tbee.util.pool.JdbcConnectionPoolFactory.TEST.JdbcDriver=com.nilostep.xlsql.jdbc.xlDriver org.tbee.util.pool.JdbcConnectionPoolFactory.TEST.JdbcUrl=jdbc:nilostep:excel:C:/DOCUME~1/tom/MYDOCU~1/kp/jars/jars/container/Util.jar/libtest org.tbee.util.pool.JdbcConnectionPoolFactory.TEST.JdbcUser=TBEEUTIL org.tbee.util.pool.JdbcConnectionPoolFactory.TEST.JdbcPassword=TBEEUTIL org.tbee.util.pool.JdbcConnectionPoolFactory.TEST.maxActive=15 org.tbee.util.pool.JdbcConnectionPoolFactory.TEST.maxIdle=-1 org.tbee.util.pool.JdbcConnectionPoolFactory.TEST.whenExhaustedAction=FAIL org.tbee.util.pool.JdbcConnectionPoolFactory.TEST.exhaustedWaitMax=-1

Version:
$Revision: 1.2 $

Field Summary
static String SOURCECODE_VERSION
          Standard variable for determining version of a class file.
 
Constructor Summary
JdbcConnectionPoolFactory(String poolname, ConfigurationProperties configurationProperties)
          initialize the JDBC connection pool factory
JdbcConnectionPoolFactory(String poolname, String applicationname)
          initialize the JDBC connection pool factory
 
Method Summary
 void activateObject(Object arg0)
           
static JdbcConnectionPool createConnectionPool(String poolname)
           
static JdbcConnectionPool createConnectionPool(String poolname, ConfigurationProperties configurationProperties)
          Create a factory and a pool (using the GenericObjectPool)
static JdbcConnectionPool createConnectionPool(String poolname, ConfigurationProperties configurationProperties, JdbcConnectionPoolFactory jdbcConnectionPoolFactory)
          Create a pool (using the GenericObjectPool)
static JdbcConnectionPool createConnectionPool(String poolname, String applicationname)
          Create a factory and a pool (using the GenericObjectPool)
static JdbcConnectionPool createConnectionPool(String poolname, String applicationname, JdbcConnectionPoolFactory jdbcConnectionPoolFactory)
          Create a pool (using the GenericObjectPool)
 void destroyObject(Object arg0)
           
 boolean getAutoCommit()
           
static JdbcConnectionPool getConnectionPool(Map storage, String poolname)
           
static JdbcConnectionPool getConnectionPool(Map storage, String poolname, ConfigurationProperties configurationProperties)
          Get the database pool from a map or create one
static JdbcConnectionPool getConnectionPool(Map storage, String poolname, String applicationname)
          Get the database pool from a map or create one
static JdbcConnectionPool getConnectionPool(String poolname)
           
static JdbcConnectionPool getConnectionPool(String poolname, ConfigurationProperties configurationProperties)
          Get the database pool from the embedded map
static JdbcConnectionPool getConnectionPool(String poolname, String applicationname)
          Get the database pool from the embedded map
 boolean getLogging()
           
 String getPoolname()
           
 String getPoolnameDescription()
           
 boolean getReadOnly()
           
 Object makeObject()
           
 void passivateObject(Object arg0)
           
 void setAutoCommit(boolean value)
           
 void setLogging(boolean value)
           
protected  void setPoolname(String value)
           
 void setReadOnly(boolean value)
           
 boolean validateObject(Object arg0)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SOURCECODE_VERSION

public static final String SOURCECODE_VERSION
Standard variable for determining version of a class file.

See Also:
Constant Field Values
Constructor Detail

JdbcConnectionPoolFactory

public JdbcConnectionPoolFactory(String poolname,
                                 String applicationname)
initialize the JDBC connection pool factory


JdbcConnectionPoolFactory

public JdbcConnectionPoolFactory(String poolname,
                                 ConfigurationProperties configurationProperties)
initialize the JDBC connection pool factory

Method Detail

getPoolname

public String getPoolname()

setPoolname

protected void setPoolname(String value)

getPoolnameDescription

public String getPoolnameDescription()

makeObject

public Object makeObject()
Specified by:
makeObject in interface PoolableObjectFactory

destroyObject

public void destroyObject(Object arg0)
Specified by:
destroyObject in interface PoolableObjectFactory

validateObject

public boolean validateObject(Object arg0)
Specified by:
validateObject in interface PoolableObjectFactory

activateObject

public void activateObject(Object arg0)
Specified by:
activateObject in interface PoolableObjectFactory

passivateObject

public void passivateObject(Object arg0)
Specified by:
passivateObject in interface PoolableObjectFactory

getAutoCommit

public boolean getAutoCommit()

setAutoCommit

public void setAutoCommit(boolean value)

getReadOnly

public boolean getReadOnly()

setReadOnly

public void setReadOnly(boolean value)

getLogging

public boolean getLogging()

setLogging

public void setLogging(boolean value)

createConnectionPool

public static JdbcConnectionPool createConnectionPool(String poolname,
                                                      String applicationname)
Create a factory and a pool (using the GenericObjectPool)

Returns:

createConnectionPool

public static JdbcConnectionPool createConnectionPool(String poolname,
                                                      ConfigurationProperties configurationProperties)
Create a factory and a pool (using the GenericObjectPool)

Returns:

createConnectionPool

public static JdbcConnectionPool createConnectionPool(String poolname,
                                                      String applicationname,
                                                      JdbcConnectionPoolFactory jdbcConnectionPoolFactory)
Create a pool (using the GenericObjectPool)

Returns:

createConnectionPool

public static JdbcConnectionPool createConnectionPool(String poolname,
                                                      ConfigurationProperties configurationProperties,
                                                      JdbcConnectionPoolFactory jdbcConnectionPoolFactory)
Create a pool (using the GenericObjectPool)

Returns:

createConnectionPool

public static JdbcConnectionPool createConnectionPool(String poolname)

getConnectionPool

public static JdbcConnectionPool getConnectionPool(Map storage,
                                                   String poolname,
                                                   String applicationname)
Get the database pool from a map or create one


getConnectionPool

public static JdbcConnectionPool getConnectionPool(Map storage,
                                                   String poolname,
                                                   ConfigurationProperties configurationProperties)
Get the database pool from a map or create one


getConnectionPool

public static JdbcConnectionPool getConnectionPool(Map storage,
                                                   String poolname)

getConnectionPool

public static JdbcConnectionPool getConnectionPool(String poolname,
                                                   String applicationname)
Get the database pool from the embedded map


getConnectionPool

public static JdbcConnectionPool getConnectionPool(String poolname,
                                                   ConfigurationProperties configurationProperties)
Get the database pool from the embedded map


getConnectionPool

public static JdbcConnectionPool getConnectionPool(String poolname)


Copyright © 2012 KnowledgePlaza. All Rights Reserved.