Apache JMeter
1.9

org.apache.jmeter.protocol.jdbc.util
Class DBConnectionManager

java.lang.Object
  |
  +--org.apache.jmeter.protocol.jdbc.util.DBConnectionManager

public class DBConnectionManager
extends Object

This class manages a pool of Connection objects (ConnectionObject). This pool is constantly checked for old, over-used, or dead connections in a separated thread. Connections are rented out and then given back by the DBConnect object and its subclasses. This class is not directly accessed by the end-user objects. It is accessed by the DBConnect object and its subclasses.

Version:
$Revision: 1.7 $
Author:
Michael Stover

Method Summary
 void close(DBKey key)
          Closes out this object and returns resources to the system.
 Connection getConnection(DBKey key)
          Rents out a database connection object.
 DBKey getKey(String url, String username, String password, String driver, int maxUsage, int maxConnections)
          Starts the connection manager going for a given database connection, and returns the DBKey object required to get a Connection object for this database.
static DBConnectionManager getManager()
           
 Connection newConnection(DBKey key)
          Returns a new java.sql.Connection object.
 boolean registerDriver(String driver)
          Registers a driver for a database.
 void releaseConnection(Connection c)
          Releases a connection back to the pool.
 void setup(DBKey key)
          Constructor.
 void shutdown()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getManager

public static DBConnectionManager getManager()

getKey

public DBKey getKey(String url,
                    String username,
                    String password,
                    String driver,
                    int maxUsage,
                    int maxConnections)
Starts the connection manager going for a given database connection, and returns the DBKey object required to get a Connection object for this database.

Parameters:
url - URL of database to be connected to.
username - username to use to connect to database.
password - password to use to connect to database.
driver - driver to use for the database.
maxUsage - sets the maxUsage parameter for connections to this database.
maxConnections - tells the DBConnectionManager how many connections to keep active.
Returns:
DBKey object. Returns null if connection fails.

setup

public void setup(DBKey key)
Constructor.

Parameters:
key - DBKey that holds all information needed to set up a set of connections.

shutdown

public void shutdown()

getConnection

public Connection getConnection(DBKey key)
                         throws NoConnectionsAvailableException
Rents out a database connection object.

Returns:
Connection object.
NoConnectionsAvailableException

releaseConnection

public void releaseConnection(Connection c)
Releases a connection back to the pool.

Parameters:
c - Connection object being returned

newConnection

public Connection newConnection(DBKey key)
                         throws SQLException
Returns a new java.sql.Connection object.

Throws:
SQLException

close

public void close(DBKey key)
Closes out this object and returns resources to the system.


registerDriver

public boolean registerDriver(String driver)
Registers a driver for a database.

Parameters:
driver - full classname for the driver.
Returns:
True if successful, false otherwise.

Apache JMeter
1.9

Copyright © 1998-2003 Apache Software Foundation. All Rights Reserved.