org.dmonix.jdbc
Class DMConnectionPool

java.lang.Object
  extended byorg.dmonix.jdbc.DMConnectionPool

public class DMConnectionPool
extends java.lang.Object

The class makes connections available to calling program in its getConnection method.
This method searches for an available connection in the connection pool.
If no connection is available from the pool, a new connection is created.
If a connection is available from the pool, the getConnection method leases the connection and returns it to the calling program.

Copyright: Copyright (c) 2003

Company: dmonix.org

Version:
1.0
Author:
Peter Nerg

Constructor Summary
DMConnectionPool(java.lang.String url, java.lang.String user, java.lang.String password, int initialSize)
          Constructs a pool of the initial size.
DMConnectionPool(java.lang.String url, java.lang.String user, java.lang.String password, int initialSize, boolean autoCommit)
          Constructs a pool of the initial size.
 
Method Summary
 void closeConnections()
          This will close and remove all connections from the pool.
 java.sql.Connection getConnection()
          The method searches for an available connection in the connection pool.
 void reapConnections()
          The method will remove any hanging, dead connections.
 void removeConnection(DMConnection conn)
          This will remove one connection from the pool.
 void returnConnection(DMConnection conn)
          This will return a connection to the pool.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DMConnectionPool

public DMConnectionPool(java.lang.String url,
                        java.lang.String user,
                        java.lang.String password,
                        int initialSize,
                        boolean autoCommit)
                 throws java.sql.SQLException
Constructs a pool of the initial size.

Parameters:
url - The URL for the connection
user - The user for the connection
password - The password for the connection
initialSize - The initial size of the pool
autoCommit - If the connections shall be autocommiting
Throws:
java.sql.SQLException

DMConnectionPool

public DMConnectionPool(java.lang.String url,
                        java.lang.String user,
                        java.lang.String password,
                        int initialSize)
                 throws java.sql.SQLException
Constructs a pool of the initial size.

Parameters:
url - The URL for the connection
user - The suer for the connection
password - The password for the connection
initialSize - The initial size of the pool
Throws:
java.sql.SQLException
Method Detail

reapConnections

public void reapConnections()
The method will remove any hanging, dead connections.
A connection is dead if the following conditions are met.


closeConnections

public void closeConnections()
This will close and remove all connections from the pool.


removeConnection

public void removeConnection(DMConnection conn)
This will remove one connection from the pool.

Parameters:
conn - The connection to remove

getConnection

public java.sql.Connection getConnection()
                                  throws java.sql.SQLException
The method searches for an available connection in the connection pool.
If no connection is available from the pool, the method is put on hold using wait(). If a connection is available from the pool, the getConnection method leases the connection and returns it to the calling program

Returns:
The connection
Throws:
java.sql.SQLException

returnConnection

public void returnConnection(DMConnection conn)
This will return a connection to the pool.
If the pool was previously empty, the method invokes notify() in order to release any thread waiting in the method getConnection()

Parameters:
conn - The connection to return


Copyright © 1998-2005 dmonix.org Peter Nerg, All Rights Reserved.