raccoon.core.jdbc
Class ConnectionPool

java.lang.Object
  extended by raccoon.core.jdbc.ConnectionPool

public class ConnectionPool
extends java.lang.Object

The pool manager for the various JDBC connections that have been loaded..

Since:
Raccoon v0.9
Version:
0.9
Author:
Cedric ROUVRAIS

Field Summary
static int POOL_SIZE
          The initial pool size.
 
Constructor Summary
ConnectionPool(java.lang.String pDbConnectionString, java.lang.String pDbUserName, java.lang.String pDbPassword)
          Creates the pool monitor and sets the fields of this instance.
 
Method Summary
 void closeConnections()
          Closes all the known connections and releases resources.
protected  void finalize()
          Invokes closeConnections().
 Connection getConnection()
          Retrieves a connection, creates a new one if required.
 void reapConnections()
          Removes connections that haven't been used for a while.
 void returnConnection(Connection pConnection)
          Frees the given JDBC connection.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

POOL_SIZE

public static final int POOL_SIZE
The initial pool size.

See Also:
Constant Field Values
Constructor Detail

ConnectionPool

public ConnectionPool(java.lang.String pDbConnectionString,
                      java.lang.String pDbUserName,
                      java.lang.String pDbPassword)
Creates the pool monitor and sets the fields of this instance.

Parameters:
pDbConnectionString - the database connection string to use.
pDbUserName - the name of the database user.
pDbPassword - the database password of the provided user.
Method Detail

reapConnections

public void reapConnections()
Removes connections that haven't been used for a while.


closeConnections

public void closeConnections()
Closes all the known connections and releases resources.


finalize

protected void finalize()
                 throws java.lang.Throwable
Invokes closeConnections().

Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable - in case of an unhandled error.

getConnection

public Connection getConnection()
                         throws java.sql.SQLException
Retrieves a connection, creates a new one if required.

Returns:
a connection from the pool.
Throws:
java.sql.SQLException - if the connection couldn't be obtained.

returnConnection

public void returnConnection(Connection pConnection)
Frees the given JDBC connection.

Parameters:
pConnection - the JDBC connection.


Copyright null null. All Rights Reserved.