org.jaffa.persistence.engines.jdbcengine.datasource
Class DbcpDataSourceConnectionFactory

java.lang.Object
  extended byorg.jaffa.persistence.engines.jdbcengine.datasource.DbcpDataSourceConnectionFactory
All Implemented Interfaces:
IConnectionFactory

public class DbcpDataSourceConnectionFactory
extends Object
implements IConnectionFactory

This is a Dbcp DataSource based implementation of IConnectionFactory. It requires commons-collections.jar, commons-pool.jar, commons-dbcp.jar, j2ee.jar (for the javax.sql classes), the classes for your (underlying) JDBC driver in the classpath.

Author:
GautamJ

Constructor Summary
DbcpDataSourceConnectionFactory()
           
 
Method Summary
 Connection createConnection()
          Creates a connection using Dbcp DataSource implementation.
 void freeConnection(Connection connection)
          Returns the connection back to the pool.
 String getDriverClass()
          Getter for property driverClass.
 Integer getMaximumConnections()
          Getter for property maximumConnections.
 Long getMaxWait()
          Getter for property maxWait.
 Integer getMinimumConnections()
          Getter for property minimumConnections.
 String getPassword()
          Getter for property password.
 Boolean getTestOnBorrow()
          Getter for property testOnBorrow.
 Boolean getTestOnReturn()
          Getter for property testOnReturn.
 String getUrl()
          Getter for property url.
 String getUser()
          Getter for property user.
 String getValidationQuery()
          Getter for property validationQuery.
 void setDriverClass(String driverClass)
          Setter for property driverClass.
 void setMaximumConnections(Integer maximumConnections)
          Setter for property maximumConnections.
 void setMaxWait(Long maxWait)
          Setter for property maxWait.
 void setMinimumConnections(Integer minimumConnections)
          Setter for property minimumConnections.
 void setPassword(String password)
          Setter for property password.
 void setTestOnBorrow(Boolean testOnBorrow)
          Setter for property testOnBorrow.
 void setTestOnReturn(Boolean testOnReturn)
          Setter for property testOnReturn.
 void setUrl(String url)
          Setter for property url.
 void setUser(String user)
          Setter for property user.
 void setValidationQuery(String validationQuery)
          Setter for property validationQuery.
 boolean usePreparedStatementCaching()
          Returns a true if the Prepared (and Call) Statements are to be cached for a connection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DbcpDataSourceConnectionFactory

public DbcpDataSourceConnectionFactory()
Method Detail

getDriverClass

public String getDriverClass()
Getter for property driverClass.

Returns:
Value of property driverClass.

setDriverClass

public void setDriverClass(String driverClass)
Setter for property driverClass.

Parameters:
driverClass - New value of property driverClass.

getUrl

public String getUrl()
Getter for property url.

Returns:
Value of property url.

setUrl

public void setUrl(String url)
Setter for property url.

Parameters:
url - New value of property url.

getUser

public String getUser()
Getter for property user.

Returns:
Value of property user.

setUser

public void setUser(String user)
Setter for property user.

Parameters:
user - New value of property user.

getPassword

public String getPassword()
Getter for property password.

Returns:
Value of property password.

setPassword

public void setPassword(String password)
Setter for property password.

Parameters:
password - New value of property password.

getMinimumConnections

public Integer getMinimumConnections()
Getter for property minimumConnections.

Returns:
Value of property minimumConnections.

setMinimumConnections

public void setMinimumConnections(Integer minimumConnections)
Setter for property minimumConnections.

Parameters:
minimumConnections - New value of property minimumConnections.

getMaximumConnections

public Integer getMaximumConnections()
Getter for property maximumConnections.

Returns:
Value of property maximumConnections.

setMaximumConnections

public void setMaximumConnections(Integer maximumConnections)
Setter for property maximumConnections.

Parameters:
maximumConnections - New value of property maximumConnections.

getMaxWait

public Long getMaxWait()
Getter for property maxWait.

Returns:
Value of property maxWait.

setMaxWait

public void setMaxWait(Long maxWait)
Setter for property maxWait.

Parameters:
maxWait - New value of property maxWait.

getTestOnBorrow

public Boolean getTestOnBorrow()
Getter for property testOnBorrow.

Returns:
Value of property testOnBorrow.

setTestOnBorrow

public void setTestOnBorrow(Boolean testOnBorrow)
Setter for property testOnBorrow.

Parameters:
testOnBorrow - New value of property testOnBorrow.

getTestOnReturn

public Boolean getTestOnReturn()
Getter for property testOnReturn.

Returns:
Value of property testOnReturn.

setTestOnReturn

public void setTestOnReturn(Boolean testOnReturn)
Setter for property testOnReturn.

Parameters:
testOnReturn - New value of property testOnReturn.

getValidationQuery

public String getValidationQuery()
Getter for property validationQuery.

Returns:
Value of property validationQuery.

setValidationQuery

public void setValidationQuery(String validationQuery)
Setter for property validationQuery.

Parameters:
validationQuery - New value of property validationQuery.

createConnection

public Connection createConnection()
                            throws SQLException,
                                   IOException
Creates a connection using Dbcp DataSource implementation.

Specified by:
createConnection in interface IConnectionFactory
Returns:
a Connection
Throws:
SQLException - if any SQL error occurs
IOException - if any IO error occurs

freeConnection

public void freeConnection(Connection connection)
                    throws SQLException,
                           IOException
Returns the connection back to the pool.

Specified by:
freeConnection in interface IConnectionFactory
Parameters:
connection - The connection to return back to the pool.
Throws:
SQLException - if any SQL error occurs
IOException - if any IO error occurs

usePreparedStatementCaching

public boolean usePreparedStatementCaching()
Returns a true if the Prepared (and Call) Statements are to be cached for a connection. This will return a false. It uses the StackKeyedObjectPoolFactory for creating a pool for caching the PreparedStatements.

Specified by:
usePreparedStatementCaching in interface IConnectionFactory
Returns:
a true if the Prepared (and Call) Statements are to be cached for a connection.


Copyright © 2002-2004 JAFFA Project.