jPOS 1.6.1 API Documentation

org.jpos.tpl
Class ConnectionPool

java.lang.Object
  extended by org.jpos.tpl.ConnectionPool
All Implemented Interfaces:
java.lang.Runnable, Configurable, LogSource

public class ConnectionPool
extends java.lang.Object
implements java.lang.Runnable, LogSource, Configurable

A class for preallocating, recycling, and managing JDBC connections.

Taken from Core Servlets and JavaServer Pages from Prentice Hall and Sun Microsystems Press, http://www.coreservlets.com/. © 2000 Marty Hall; may be freely used or adapted.

Version:
$Revision: 2594 $ $Date: 2008-01-22 08:41:31 -0800 (Tue, 22 Jan 2008) $
Author:
Rajal Shah

Constructor Summary
ConnectionPool()
          no args constructor
ConnectionPool(java.lang.String driver, java.lang.String url, java.lang.String username, java.lang.String password, int initialConnections, int maxConnections, boolean waitIfBusy)
          To invoke the Connection Pool object directly without jPOS.
 
Method Summary
 void closeAllConnections()
          Close all the connections.
 void free(java.sql.Connection connection)
           
 java.sql.Connection getConnection()
           
static ConnectionPool getConnectionPool(java.lang.String name)
           
 Logger getLogger()
           
 java.lang.String getRealm()
           
 int getTotalConnections()
           
 void run()
           
 void setConfiguration(Configuration cfg)
           
 void setLogger(Logger logger, java.lang.String realm)
           
 java.lang.String toString()
           
 int totalConnections()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ConnectionPool

public ConnectionPool()
no args constructor


ConnectionPool

public ConnectionPool(java.lang.String driver,
                      java.lang.String url,
                      java.lang.String username,
                      java.lang.String password,
                      int initialConnections,
                      int maxConnections,
                      boolean waitIfBusy)
               throws java.sql.SQLException
To invoke the Connection Pool object directly without jPOS.

Throws:
java.sql.SQLException
Method Detail

setConfiguration

public void setConfiguration(Configuration cfg)
                      throws ConfigurationException
Specified by:
setConfiguration in interface Configurable
Parameters:
cfg - Configuration object
Throws:
ConfigurationException

getConnection

public java.sql.Connection getConnection()
                                  throws java.sql.SQLException
Throws:
java.sql.SQLException

run

public void run()
Specified by:
run in interface java.lang.Runnable

free

public void free(java.sql.Connection connection)

totalConnections

public int totalConnections()

getTotalConnections

public int getTotalConnections()

closeAllConnections

public void closeAllConnections()
Close all the connections. Use with caution: be sure no connections are in use before calling. Note that you are not required to call this when done with a ConnectionPool, since connections are guaranteed to be closed when garbage collected. But this method gives more control regarding when the connections are closed.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

setLogger

public void setLogger(Logger logger,
                      java.lang.String realm)
Specified by:
setLogger in interface LogSource

getRealm

public java.lang.String getRealm()
Specified by:
getRealm in interface LogSource

getLogger

public Logger getLogger()
Specified by:
getLogger in interface LogSource

getConnectionPool

public static ConnectionPool getConnectionPool(java.lang.String name)
                                        throws NameRegistrar.NotFoundException
Returns:
ISOMUX instance with given name.
Throws:
NameRegistrar.NotFoundException;
NameRegistrar.NotFoundException
See Also:
NameRegistrar

jPOS.org