org.jcreme.sql
Interface ConnectionPool

All Known Implementing Classes:
WrappedConnectionPool

public interface ConnectionPool

This interface models a pool of database Connection instances. A pool is a set of reusable instances, possibly with a limited number of instances.

Version:
$Revision: 1.1 $
Author:
$Author: dbregeon $

Method Summary
 void close()
          This method signals the pool it should close all the available connections.
 java.sql.Connection getConnection()
          This method provides a Connection to the database from the pool.
 java.sql.Connection getConnection(int waitingPeriod)
          This method provides a Connection to the database from the pool.
 void releaseConnection(java.sql.Connection conn)
          This method enables to return a Connection to the pool.
 void setAutoCommit(boolean autoCommit)
          This method enables to change the commit policy of the ConnectionPool.
 void setMaximumSize(int maxSize)
          This method enables to change the maximum size of the ConnectionPool.
 void setMinimumSize(int minSize)
          This method enables to change the minimum size of the ConnectionPool.
 void setTransactionIsolation(IsolationLevel isolationLevel)
          This method enables to change the isolation level used in the ConnectionPool.
 

Method Detail

getConnection

public java.sql.Connection getConnection()
                                  throws java.sql.SQLException
This method provides a Connection to the database from the pool. The Connection may be created on the spot or already exists. The pool guarantees that the Connection was released by its previous user, not that the previous user actually ceased to use it.

Returns:
a ready to use Connection.
Throws:
java.sql.SQLException - if a problem occurs while trying to get a Connection.

getConnection

public java.sql.Connection getConnection(int waitingPeriod)
                                  throws java.sql.SQLException
This method provides a Connection to the database from the pool. The Connection may be created on the spot or already exists. The pool guarantees that the Connection was released by its previous user, not that the previous user actually ceased to use it. If the waiting period expires and no connection was available, it will return null.

Parameters:
waitingPeriod - the number of milliseconds for which the method call will be blocked waiting for an available connection.
Returns:
a ready to use Connection or null if the waiting period expired.
Throws:
java.sql.SQLException - if a problem occurs while trying to get a Connection.

releaseConnection

public void releaseConnection(java.sql.Connection conn)
                       throws java.sql.SQLException
This method enables to return a Connection to the pool. Nothing is done if the Connection does not belong to the pool. The Connection should not be used after being released.

Parameters:
conn - the Connection to be returned.
Throws:
java.sql.SQLException - if a problem occurs while trying to release a Connection.

close

public void close()
           throws java.sql.SQLException
This method signals the pool it should close all the available connections. This method usually is called when exiting an application. Connections provided by this pool should not be used after the close method has been called.

Throws:
java.sql.SQLException - if an error occurs while closing the pool.

setTransactionIsolation

public void setTransactionIsolation(IsolationLevel isolationLevel)
                             throws java.sql.SQLException
This method enables to change the isolation level used in the ConnectionPool.

Parameters:
isolationLevel - the new isolation level to apply.
Throws:
java.sql.SQLException - if a problem occurs while changing the isolation level.

setMinimumSize

public void setMinimumSize(int minSize)
                    throws java.sql.SQLException
This method enables to change the minimum size of the ConnectionPool.

Parameters:
minSize - the new minimum size to apply.
Throws:
java.sql.SQLException - if a problem occurs while changing the pool minimum size.

setMaximumSize

public void setMaximumSize(int maxSize)
                    throws java.sql.SQLException
This method enables to change the maximum size of the ConnectionPool.

Parameters:
maxSize - the new maximum size to apply.
Throws:
java.sql.SQLException - if a problem occurs while changing the pool maximum size.

setAutoCommit

public void setAutoCommit(boolean autoCommit)
                   throws java.sql.SQLException
This method enables to change the commit policy of the ConnectionPool.

Parameters:
autoCommit - the new commit policy to apply.
Throws:
java.sql.SQLException - if a problem occurs while changing the commit policy.


Copyright 2006 null. All Rights Reserved.