com.xmlserv.util
Class PGConnectionPool

java.lang.Object
  |
  +--com.xmlserv.util.PGConnectionPool
All Implemented Interfaces:
ConnectionPool

public class PGConnectionPool
extends java.lang.Object
implements ConnectionPool

An implementation of the ConnectionPool interface for the PostgreSQL Database. The connection URL has the following format:
jdbc:postgresql://host:port/database

Version:
$Id: PGConnectionPool.java,v 1.10 2002/08/15 22:45:53 muecke Exp $
Author:
Wolfram Saringer

Constructor Summary
PGConnectionPool()
          Instantiate without connecting.
PGConnectionPool(java.lang.String url, java.lang.String username, java.lang.String password)
          Connect to the given DB, initializing the pool with default size.
PGConnectionPool(java.lang.String url, java.lang.String username, java.lang.String password, int startPoolSize)
          Connect to the given DB, initializing the pool with the given number of connections.
 
Method Summary
 java.sql.Connection checkoutConn()
          Get a connection.
 void destroy()
          Destroy pool, closing all DB connections.
 int getPoolIncrement()
           
 java.lang.String getStatus()
          Get status report.
 void init(java.lang.String url, java.lang.String username, java.lang.String password, int startPoolSize)
          Initialize object with given number of connections.
 void returnConn(java.sql.Connection conn)
          Return a Connection object.
 void setPoolIncrement(int incr)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PGConnectionPool

public PGConnectionPool()
Instantiate without connecting.

PGConnectionPool

public PGConnectionPool(java.lang.String url,
                        java.lang.String username,
                        java.lang.String password,
                        int startPoolSize)
                 throws java.sql.SQLException
Connect to the given DB, initializing the pool with the given number of connections.
Parameters:
url - The connection URL in the format jdbc:postgresql://host:port/database.
username - The username for authentication.
password - The corresponding password.
startPoolSize - The initial pool size.
Throws:
java.sql.SQLException - Upon failure.

PGConnectionPool

public PGConnectionPool(java.lang.String url,
                        java.lang.String username,
                        java.lang.String password)
                 throws java.sql.SQLException
Connect to the given DB, initializing the pool with default size.
Parameters:
url - The connection URL in the format jdbc:postgresql://host:port/database.
username - The username for authentication.
password - The corresponding password.
Throws:
java.sql.SQLException - Upon failure.
Method Detail

init

public void init(java.lang.String url,
                 java.lang.String username,
                 java.lang.String password,
                 int startPoolSize)
          throws java.sql.SQLException
Initialize object with given number of connections.
Specified by:
init in interface ConnectionPool
Parameters:
url - The connection URL in the format jdbc:postgresql://host:port/database.
username - The username for authentication.
password - The corresponding password.
startPoolSize - The initial pool size.
Throws:
java.sql.SQLException - Upon failure.

destroy

public void destroy()
Destroy pool, closing all DB connections.
Specified by:
destroy in interface ConnectionPool

getStatus

public java.lang.String getStatus()
Get status report.
Returns:
A short status report containing pool size and number of free connections.

checkoutConn

public java.sql.Connection checkoutConn()
                                 throws java.sql.SQLException
Get a connection.
Specified by:
checkoutConn in interface ConnectionPool
Returns:
A Connection object with autoCommit set to true.
Throws:
java.sql.SQLException - If pool is empty and cannot be grown.

returnConn

public void returnConn(java.sql.Connection conn)
                throws java.sql.SQLException
Return a Connection object. AutoCommit will be reset to true.
Specified by:
returnConn in interface ConnectionPool
Parameters:
conn - The Connection to return.
Throws:
java.sql.SQLException - Indicates a Problem shrinking the pool.

setPoolIncrement

public void setPoolIncrement(int incr)

getPoolIncrement

public int getPoolIncrement()