jodd.db.pool
Class CoreConnectionPool

java.lang.Object
  extended by jodd.db.pool.CoreConnectionPool
All Implemented Interfaces:
java.lang.Runnable, ConnectionProvider

public class CoreConnectionPool
extends java.lang.Object
implements java.lang.Runnable, ConnectionProvider

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

It uses threads for opening a new connextion. When no connection available it will wait until a connection is released.

todo Replace arraylist with stack todo Add thread for cleaning non-necessary connections, from time to time.


Constructor Summary
CoreConnectionPool()
           
 
Method Summary
 void close()
          Close all the connections.
 void closeConnection(java.sql.Connection connection)
          Dispose of a used connection.
 java.sql.Connection getConnection()
          Get a connection.
 int[] getConnectionsCount()
          Returns connection number statistics in the following order: total connections availiable connections busy connections
 java.lang.String getDriver()
           
 int getMaxConnections()
           
 int getMinConnections()
           
 java.lang.String getPassword()
           
 java.lang.String getUrl()
           
 java.lang.String getUser()
           
 void init()
          Initialize the connection provider.
 boolean isWaitIfBusy()
           
 void run()
           
 void setDriver(java.lang.String driver)
           
 void setMaxConnections(int maxConnections)
           
 void setMinConnections(int minConnections)
           
 void setPassword(java.lang.String password)
           
 void setUrl(java.lang.String url)
           
 void setUser(java.lang.String user)
           
 void setWaitIfBusy(boolean waitIfBusy)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CoreConnectionPool

public CoreConnectionPool()
Method Detail

getDriver

public java.lang.String getDriver()

setDriver

public void setDriver(java.lang.String driver)

getUrl

public java.lang.String getUrl()

setUrl

public void setUrl(java.lang.String url)

getUser

public java.lang.String getUser()

setUser

public void setUser(java.lang.String user)

getPassword

public java.lang.String getPassword()

setPassword

public void setPassword(java.lang.String password)

getMaxConnections

public int getMaxConnections()

setMaxConnections

public void setMaxConnections(int maxConnections)

getMinConnections

public int getMinConnections()

setMinConnections

public void setMinConnections(int minConnections)

isWaitIfBusy

public boolean isWaitIfBusy()

setWaitIfBusy

public void setWaitIfBusy(boolean waitIfBusy)

init

public void init()
Description copied from interface: ConnectionProvider
Initialize the connection provider. Properties are provided either with constructor either with bean setters.

Specified by:
init in interface ConnectionProvider

getConnection

public java.sql.Connection getConnection()
Description copied from interface: ConnectionProvider
Get a connection.

Specified by:
getConnection in interface ConnectionProvider

run

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

closeConnection

public void closeConnection(java.sql.Connection connection)
Description copied from interface: ConnectionProvider
Dispose of a used connection.

Specified by:
closeConnection in interface ConnectionProvider

getConnectionsCount

public int[] getConnectionsCount()
Returns connection number statistics in the following order:
  1. total connections
  2. availiable connections
  3. busy connections


close

public void close()
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.

Specified by:
close in interface ConnectionProvider


Copyright ©2008 Jodd Team