org.openrdf.util.jdbc
Class ConnectionPool

java.lang.Object
  extended byorg.openrdf.util.jdbc.ConnectionPool

public class ConnectionPool
extends Object


Constructor Summary
ConnectionPool(String url, String user, String password)
           
 
Method Summary
 void drain()
          Drains the pool.
 Connection getConnection()
           
 int getPoolSize()
           
 void removeExpired()
           
 void setCheckConnections(boolean checkConnections)
          Sets the flag that determines whether the the status of connections (closed, has warnings) is checked before they are returned by getConnection().
 void setCleaningInterval(long cleaningInterval)
          Sets the interval for the pool cleaner to come into action.
 void setMaxIdleTime(long maxIdleTime)
          Sets the maximum time that a connection is allowed to be idle.
 void setMaxUseTime(long maxUseTime)
          Sets the maximum time that a connection is allowed to be used.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConnectionPool

public ConnectionPool(String url,
                      String user,
                      String password)
Method Detail

setCheckConnections

public void setCheckConnections(boolean checkConnections)
Sets the flag that determines whether the the status of connections (closed, has warnings) is checked before they are returned by getConnection(). With some jdbc-drivers, the extra checks can have a large performance penalty. Default value is 'true'.


setCleaningInterval

public void setCleaningInterval(long cleaningInterval)
Sets the interval for the pool cleaner to come into action. The pool cleaner checks the connection pool every so many milliseconds for connections that should be removed. The default interval is 30 seconds.

Parameters:
cleaningInterval - The interval in milliseconds.

setMaxIdleTime

public void setMaxIdleTime(long maxIdleTime)
Sets the maximum time that a connection is allowed to be idle. A connection that has been idle for a longer time will be removed by the pool cleaner the next time it check the pool. The default value is 30 seconds.

Parameters:
maxIdleTime - The maximum idle time in milliseconds.

setMaxUseTime

public void setMaxUseTime(long maxUseTime)
Sets the maximum time that a connection is allowed to be used. A connection that has been used for a longer time will be forced to close itself, even if it is still in use. Normally, this time should only be reached in case an program "forgets" to close a connection. The maximum time is switched of by default.

Parameters:
maxUseTime - The maximum time a connection can be used in milliseconds, or a negative value if there is no maximum.

getConnection

public Connection getConnection()
                         throws SQLException
Throws:
SQLException

removeExpired

public void removeExpired()

getPoolSize

public int getPoolSize()

drain

public void drain()
Drains the pool. After the ConnectionPool has been drained it will not give out any more connections and all existing connections will be closed. This action cannot be reversed, so a ConnectionPool will become unusable once it has been drained.



Copyright © 2002-2006 Aduna BV, GNU LGPL License applies.