com.tivoli.twg.engine
Class TWGDbConnection

java.lang.Object
  extended bycom.tivoli.twg.engine.TWGDbConnection

public class TWGDbConnection
extends java.lang.Object

TWGDbConnection is a wrapper class for java.sql.Connection. It keeps additional information about the status of the connection such as number of users, as well as a reference to the database for the connection

IBM Director extensions should use the command interface (eg. TWGDbRunQueryCmd) for database access. They should not instantiate their own TWGDbConnection objects. Additionally, extenstions should use the TWGDatabase.isActive() to be sure the database is active before attempting to use the database.


Method Summary
 void close()
          Close the connection to the database.
 void commit()
          Commit the updates to the database
 java.sql.Statement createStatement()
          Create a new statement on this connection
 java.sql.Statement createStatement(int resultSetType, int resultSetConcurrency)
          Create a new statement on this connection
 boolean getAutoCommit()
          Get the autoCommit state for the connection
 int getConnectionType()
          Get the connection type
 TWGDatabase getDatabase()
          Get the database that this connection is for
 java.sql.DatabaseMetaData getMetaData()
          Get the metadata for the database connection
 int getNumUsers()
          Get the number of users using this connection
 boolean getTempConn()
          Get the connection type as temporary or permanent.
 void incrementDirtyLevel()
          Increment the dirty level for this connection.
 boolean isClosed()
          Check if connection is closed
 boolean isDirty(int check)
          Check if connection is dirty (has the database had major changes since this
 boolean isReadOnly()
          Check if connection is read only
 java.sql.PreparedStatement prepareStatement(java.lang.String sqlStatement)
          Create a new prepared statement on this connection
 void rollback()
          Rollback the database updates
protected  void setTempConn(boolean isTempConn)
          Set the connection type as temporary or permanent.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getNumUsers

public int getNumUsers()
Get the number of users using this connection

Returns:
the current number of users

getDatabase

public TWGDatabase getDatabase()
Get the database that this connection is for

Returns:
the database object

getConnectionType

public int getConnectionType()
Get the connection type

Returns:
an integer that indicates which connection type is used. Possible values are found in TWGDatabaseConstants
See Also:
TWGDatabaseConstants

getMetaData

public java.sql.DatabaseMetaData getMetaData()
                                      throws TWGDbException
Get the metadata for the database connection

Returns:
a DatabaseMetaData object
Throws:
TWGDbException
See Also:
DatabaseMetaData

getAutoCommit

public boolean getAutoCommit()
                      throws TWGDbException
Get the autoCommit state for the connection

Returns:
true if autoCommit is on, otherwise false
Throws:
TWGDbException

commit

public void commit()
            throws TWGDbException
Commit the updates to the database

Throws:
TWGDbException - for any SQL error

rollback

public void rollback()
              throws TWGDbException
Rollback the database updates

Throws:
TWGDbException - for any SQL error

incrementDirtyLevel

public void incrementDirtyLevel()
Increment the dirty level for this connection. This method should be called when tables or indexes have been created, changed, or deleted. This signals that open connections to the database need to be closed and new connections established.


isDirty

public boolean isDirty(int check)
Check if connection is dirty (has the database had major changes since this

Returns:
- true if connection is dirty, otherwise false

close

public void close()
           throws TWGDbException
Close the connection to the database. This method should be called only by the Director engine.

Throws:
TWGDbException - for any SQL errors

isClosed

public boolean isClosed()
                 throws TWGDbException
Check if connection is closed

Returns:
- true if connection is closed, otherwise false
Throws:
TWGDbException - for any SQL errors

isReadOnly

public boolean isReadOnly()
                   throws TWGDbException
Check if connection is read only

Returns:
- true if connection is read only, otherwise false
Throws:
TWGDbException - for any SQL errors

createStatement

public java.sql.Statement createStatement()
                                   throws TWGDbException
Create a new statement on this connection

Returns:
- the statement
Throws:
TWGDbException - for any SQL errors
See Also:
Statement

createStatement

public java.sql.Statement createStatement(int resultSetType,
                                          int resultSetConcurrency)
                                   throws TWGDbException
Create a new statement on this connection

Returns:
- the statement
Throws:
TWGDbException - for any SQL errors
See Also:
Statement

prepareStatement

public java.sql.PreparedStatement prepareStatement(java.lang.String sqlStatement)
                                            throws TWGDbException
Create a new prepared statement on this connection

Returns:
- a prepared statement
Throws:
TWGDbException - for any SQL errors
See Also:
Statement

setTempConn

protected void setTempConn(boolean isTempConn)
Set the connection type as temporary or permanent. A temporary connection will be closed after being used. A permanent connection is kept in a connection pool.


getTempConn

public boolean getTempConn()
Get the connection type as temporary or permanent. A temporary connection will be closed after being used. A permanent connection is kept in a connection pool.