org.mmbase.module.database
Class MultiPool

java.lang.Object
  extended by org.mmbase.module.database.MultiPool

public class MultiPool
extends Object

JDBC Pool, a dummy interface to multiple real connection

Version:
$Id: MultiPool.java 34900 2009-05-01 16:29:42Z michiel $
Author:
vpro
Javadoc:

Nested Class Summary
(package private) static class MultiPool.ConnectionCloser
          Support class to close connections in a seperate thread, as some JDBC drivers have a tendency to hang themselves on a running sql close.
 
Constructor Summary
MultiPool(DatabaseSupport databaseSupport, String url, String name, String password, int conMax)
           
MultiPool(DatabaseSupport databaseSupport, String url, String name, String password, int conMax, int maxQueries)
          Establish connection to the JDBC Pool(s)
 
Method Summary
(package private)  void checkTime()
          Check the connections
protected  void createPool()
          Fills the connection pool
protected  boolean fillPool(boolean logStack)
          Fills the connection pool.
protected  void finalize()
           
 Iterator<MultiConnection> getBusyPool()
          For reporting purposes the connections in busypool can be listed.
(package private)  MultiConnection getFree()
          Get a free connection from the pool
(package private)  long getMaxLifeTime()
          Gets the time in ms how long a query may live before it is killed.
protected  MultiConnection getMultiConnection()
          Request a new 'real' Connection and wraps it in a new 'MultiConnection' object.
 Iterator<MultiConnection> getPool()
          For reporting purposes the connections in pool can be listed.
 int getSize()
          get the pool size
 int getTotalConnectionsCreated()
          get the number of statements performed
(package private)  void putBack(MultiConnection con)
          putback the used connection in the pool
protected  void replaceConnection(MultiConnection multiCon)
          Tries to fix this multi-connection if it is broken (e.g.
(package private)  void setMaxLifeTime(long maxLifeTime)
          Set the time in ms how long a query may live before it is killed.
 void shutdown()
          'realcloses' all connections.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MultiPool

MultiPool(DatabaseSupport databaseSupport,
          String url,
          String name,
          String password,
          int conMax)
    throws SQLException
Throws:
SQLException
Javadoc:

MultiPool

MultiPool(DatabaseSupport databaseSupport,
          String url,
          String name,
          String password,
          int conMax,
          int maxQueries)
    throws SQLException
Establish connection to the JDBC Pool(s)

Throws:
SQLException
Method Detail

setMaxLifeTime

void setMaxLifeTime(long maxLifeTime)
Set the time in ms how long a query may live before it is killed.

Since:
MMBase-1.8

getMaxLifeTime

long getMaxLifeTime()
Gets the time in ms how long a query may live before it is killed.

Since:
MMBase-1.8

createPool

protected void createPool()
Fills the connection pool

Since:
MMBase-1.7

fillPool

protected boolean fillPool(boolean logStack)
Fills the connection pool.

Returns:
true if the pool contains connections and mmbase can be started.
Since:
MMBase-1.7

getMultiConnection

protected MultiConnection getMultiConnection()
                                      throws SQLException
Request a new 'real' Connection and wraps it in a new 'MultiConnection' object.

Throws:
SQLException
Since:
MMBase-1.7

replaceConnection

protected void replaceConnection(MultiConnection multiCon)
                          throws SQLException
Tries to fix this multi-connection if it is broken (e.g. if database restarted).

Throws:
SQLException
Since:
MMBase-1.7.1

finalize

protected void finalize()
Overrides:
finalize in class Object

shutdown

public void shutdown()
'realcloses' all connections.

Since:
MMBase-1.6.2

checkTime

void checkTime()
Check the connections

Bad-constant:
Max life-time of a query must be configurable

getFree

MultiConnection getFree()
Get a free connection from the pool


putBack

void putBack(MultiConnection con)
putback the used connection in the pool


getSize

public int getSize()
get the pool size


getTotalConnectionsCreated

public int getTotalConnectionsCreated()
get the number of statements performed


getPool

public Iterator<MultiConnection> getPool()
For reporting purposes the connections in pool can be listed. An Iterator on a copy of the Pool is returned.

See Also:
JDBC.listConnections(org.mmbase.util.StringTagger)

getBusyPool

public Iterator<MultiConnection> getBusyPool()
For reporting purposes the connections in busypool can be listed. An Iterator on a copy of the BusyPool is returned.

See Also:
JDBC.listConnections(org.mmbase.util.StringTagger)

toString

public String toString()
Overrides:
toString in class Object
Javadoc:


MMBase 2.0-SNAPSHOT - null