amber.server.manager.database
Class DatabaseConnection

java.lang.Object
  |
  +--amber.server.manager.database.DatabaseConnection

public class DatabaseConnection
extends java.lang.Object

This is a utility class which holds information on a database connection.

See Also:
DatabaseManager

Constructor Summary
DatabaseConnection()
          Default constructor.
DatabaseConnection(java.sql.Connection connection, boolean allocated)
          Initialising constructor.
 
Method Summary
 void close()
          This function closes the connection.
 boolean equals(java.lang.Object other)
          This function determines if the input object is the same as this object.
 java.sql.Connection getConnection()
          Gets the connection in the object.
 boolean isAllocated()
          Returns the allocated state of the connection.
 boolean isClosed()
          This function checks to see if the internal connection is closed.
 void ping()
          This function performs a spurious transaction against a database.
 void setAllocated(boolean state)
          Defines whether the connection is in use.
 void setConnection(java.sql.Connection connection)
          Sets the connection in the object.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DatabaseConnection

public DatabaseConnection()
Default constructor.

DatabaseConnection

public DatabaseConnection(java.sql.Connection connection,
                          boolean allocated)
                   throws java.sql.SQLException
Initialising constructor.
Parameters:
connection - Connection to the database.
allocated - boolean true if the connection is already allocated.
Throws:
java.sql.SQLException - containing errors in getting the database meta data.
Method Detail

setConnection

public void setConnection(java.sql.Connection connection)
                   throws java.sql.SQLException
Sets the connection in the object.
Parameters:
connection - Connection to the database.
Throws:
java.sql.SQLException - containing errors in getting the database meta data.

getConnection

public java.sql.Connection getConnection()
Gets the connection in the object.
Returns:
Connection to the database.

setAllocated

public void setAllocated(boolean state)
Defines whether the connection is in use.
Parameters:
state - boolean flag the connection is allocated when true.

isAllocated

public boolean isAllocated()
Returns the allocated state of the connection.
Returns:
boolean true if the connection is allocated.

ping

public void ping()
          throws java.sql.SQLException
This function performs a spurious transaction against a database. This allows the connection to remain alive for databases where there is a connection timeout.
Throws:
java.sql.SQLException - containing errors in performing ping.

isClosed

public boolean isClosed()
                 throws java.sql.SQLException
This function checks to see if the internal connection is closed. null connections are considered to be closed.
Returns:
boolean state of the connection.
Throws:
java.sql.SQLException - containing errors in checking state.

equals

public boolean equals(java.lang.Object other)
This function determines if the input object is the same as this object. It can match Connection and DatabaseConnection objects.
Overrides:
equals in class java.lang.Object
Parameters:
other - Object to match against.
Returns:
boolean state of the comparison.

close

public void close()
           throws java.lang.IllegalStateException
This function closes the connection.
Throws:
java.lang.IllegalStateException - if the connection is allocated.


Copyright © 2002 Clearfield Research Ltd. All Rights Reserved.