Apache JMeter
2.0.1.20050615

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

java.lang.Object
  extended byorg.apache.jmeter.protocol.jdbc.util.ConnectionObject
All Implemented Interfaces:
Runnable

public class ConnectionObject
extends Object
implements Runnable

A wrapper class for a database Connection object. This class holds information about the state of the connection object in a pool managed by a DBConnectionManager object. It keeps track of how many times the connection object has been used, the time of its last usage, and whether it is currently in use.

Version:
$Revision: 1.7.2.1 $
Author:
Michael Stover

Constructor Summary
ConnectionObject(DBKey k, int maxUsage)
          Constructor - takes a connection object.
 
Method Summary
 void close()
          Closes out this object and returns resources to the system.
 Connection getCon()
          Returns the connection held by this connection object.
 boolean getInMaintenance()
          Gets whether the Connection Object is being maintained.
 boolean getInUse()
          Gets whether the connection object is currently in use.
 long getLastAccessed()
          Gets the last time this object was accessed.
 int getUseCount()
          Gets the number of times this connection object has been used.
 Connection grab()
          Grabs the connection and sets the inUse value to true.
 void release()
          Releases the connection object.
 void reset()
          Resets the use count, the last accessed time, and the in Use values and replaces the old connection object with the new one.
 void run()
          Method to run in separate thread that resets the connection object
 void setInMaintenance(boolean b)
          Sets whether the Connection Object is being maintained.
 void update()
          Updates the last accessed time for the connection object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConnectionObject

public ConnectionObject(DBKey k,
                        int maxUsage)
                 throws SQLException
Constructor - takes a connection object.

Parameters:
k - DBKey object.
maxUsage -
Method Detail

getInMaintenance

public boolean getInMaintenance()
Gets whether the Connection Object is being maintained.

Returns:
true if the ConnectionObject is being maintained, false otherwise.

setInMaintenance

public void setInMaintenance(boolean b)
Sets whether the Connection Object is being maintained.

Parameters:
b - true if the ConnectionObject is being maintained, false otherwise.

getLastAccessed

public long getLastAccessed()
Gets the last time this object was accessed.

Returns:
Time (in milliseconds) the connection object was last used

close

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


update

public void update()
Updates the last accessed time for the connection object.


getInUse

public boolean getInUse()
Gets whether the connection object is currently in use.

Returns:
True if it is in use, false otherwise.

grab

public Connection grab()
Grabs the connection and sets the inUse value to true.

Returns:
connection object

getUseCount

public int getUseCount()
Gets the number of times this connection object has been used.

Returns:
Number of times the connection object has been used.

run

public void run()
Method to run in separate thread that resets the connection object

Specified by:
run in interface Runnable

reset

public void reset()
           throws SQLException
Resets the use count, the last accessed time, and the in Use values and replaces the old connection object with the new one.

Throws:
SQLException

release

public void release()
Releases the connection object. Increments its usage count, updates the last accessed time, and returns it for use in the pool.


getCon

public Connection getCon()
Returns the connection held by this connection object.

Returns:
Connection object

Apache JMeter
2.0.1.20050615

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