Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

Connection Class Reference

#include <Connection.h>

Inheritance diagram for Connection

Inheritance graph

[legend]
List of all members.

Public Methods

virtual ~Connection ()
virtual void setAutoCommit (bool autoCommit) = 0
virtual void commit () = 0
virtual void close ()
 Doesn't actually close the connection, but instead returns itself back to the pool to be re-used. More...

virtual void rollback () = 0
virtual StatementcreateStatement () = 0
PreparedStatementprepareStatement (const nsAReadableString& sql)
CallableStatementprepareCall (const nsAReadableString& sql)
virtual const nsAReadableString& nativeSQL (const nsAReadableString& sql)
virtual bool getAutoCommit ()
virtual bool isClosed ()
virtual DatabaseMetaData* getMetaData ()
virtual void setReadOnly (bool readOnly)
virtual bool isReadOnly ()
virtual void setCatalog (const nsAReadableString& catalog)
virtual const nsAReadableString& getCatalog ()
virtual void setTransactionIsolation (int level)
virtual int getTransactionIsolation ()
virtual SQLWarning* getWarnings ()
virtual void clearWarnings ()

Protected Methods

 Connection ()
virtual ConnectionPoolgetPool () = 0
virtual PreparedStatementnewPreparedStatement (const nsAReadableString& sql) = 0
virtual CallableStatementnewCallableStatement (const nsAReadableString& sql) = 0
void run ()
 This is used by ConnectionPool.removeConnection(). More...

void closeStatements ()
 Closes all PreparedStatments and CallableStatements. More...

bool getLock ()
 Returns true if this Connection is not in use. More...

bool isLocked ()
int getCheckoutCount ()
 Returns number of times this node has been checked out from the pool. More...

long getLastAccess ()
 Returns when this connection was last checked out; 0 if it has never been used. More...

void releaseLock ()
 called by ConnectionPool.returnConnection() right before it wakes up the threads. More...

void destroy ()

Private Types

typedef std::map<const nsAReadableString*,
PreparedStatement*, compareARS
mapStringPreparedStatement
typedef std::map<const nsAReadableString*,
CallableStatement*, compareARS
mapStringCallableStatement

Private Attributes

friend ConnectionPool
bool m_locked
long m_lastAccess
bool m_free
int m_checkoutCount
mapStringPreparedStatement m_prepStmts
mapStringCallableStatement m_callStmts

Member Typedef Documentation

typedef std::map<const nsAReadableString*, CallableStatement*, compareARS> Connection::mapStringCallableStatement [private]
 

Definition at line 33 of file Connection.h.

typedef std::map<const nsAReadableString*, PreparedStatement*, compareARS> Connection::mapStringPreparedStatement [private]
 

Definition at line 30 of file Connection.h.


Constructor & Destructor Documentation

Connection::Connection ( ) [protected]
 

Definition at line 22 of file Connection.cpp.

Connection::~Connection ( ) [virtual]
 

Definition at line 43 of file Connection.cpp.


Member Function Documentation

void Connection::clearWarnings ( ) [inline, virtual]
 

Definition at line 71 of file Connection.h.

void Connection::close ( ) [virtual]
 

Doesn't actually close the connection, but instead returns itself back to the pool to be re-used.

However, if you specified maxCheckouts in the constructor, then this *will* close the JDBC Connection and re-open it if the number of checkouts has been exceeded.

Reimplemented in ConnectionDB2, ConnectionODBC, ConnectionOracle, and ConnectionSybase.

Definition at line 131 of file Connection.cpp.

Referenced by ConnectionPoolODBC::buildPool(), ConnectionSybase::close(), ConnectionOracle::close(), ConnectionODBC::close(), ConnectionDB2::close(), closeStatements(), DBPage::releaseConnection(), DBPage::rollbackConnection(), and run().

void Connection::closeStatements ( ) [protected]
 

Closes all PreparedStatments and CallableStatements.

Definition at line 71 of file Connection.cpp.

Referenced by run().

virtual void Connection::commit ( ) [pure virtual]
 

Reimplemented in ConnectionDB2, ConnectionODBC, ConnectionOracle, and ConnectionSybase.

Referenced by DBPage::releaseConnection().

virtual Statement* Connection::createStatement ( ) [pure virtual]
 

Reimplemented in ConnectionDB2, ConnectionODBC, ConnectionOracle, and ConnectionSybase.

Referenced by Transaction::aSeek(), and ConnectionPoolODBC::buildPool().

void Connection::destroy ( ) [protected]
 

Definition at line 30 of file Connection.cpp.

Referenced by ~Connection(), and ConnectionODBC::~ConnectionODBC().

bool Connection::getAutoCommit ( ) [inline, virtual]
 

Definition at line 61 of file Connection.h.

const nsAReadableString & Connection::getCatalog ( ) [virtual]
 

Definition at line 179 of file Connection.cpp.

int Connection::getCheckoutCount ( ) [protected]
 

Returns number of times this node has been checked out from the pool.

Definition at line 111 of file Connection.cpp.

Referenced by ConnectionPool::returnConnection().

long Connection::getLastAccess ( ) [protected]
 

Returns when this connection was last checked out; 0 if it has never been used.

Definition at line 120 of file Connection.cpp.

bool Connection::getLock ( ) [protected]
 

Returns true if this Connection is not in use.

Returns false if it is in use

Definition at line 87 of file Connection.cpp.

Referenced by ConnectionPool::getConnection().

DatabaseMetaData * Connection::getMetaData ( ) [inline, virtual]
 

Definition at line 63 of file Connection.h.

virtual ConnectionPool* Connection::getPool ( ) [protected, pure virtual]
 

Reimplemented in ConnectionDB2, ConnectionODBC, ConnectionOracle, and ConnectionSybase.

Referenced by close().

int Connection::getTransactionIsolation ( ) [inline, virtual]
 

Definition at line 69 of file Connection.h.

SQLWarning * Connection::getWarnings ( ) [inline, virtual]
 

Definition at line 70 of file Connection.h.

bool Connection::isClosed ( ) [inline, virtual]
 

Definition at line 62 of file Connection.h.

bool Connection::isLocked ( ) [protected]
 

Definition at line 103 of file Connection.cpp.

bool Connection::isReadOnly ( ) [inline, virtual]
 

Definition at line 65 of file Connection.h.

const nsAReadableString & Connection::nativeSQL ( const nsAReadableString & sql ) [virtual]
 

Definition at line 174 of file Connection.cpp.

virtual CallableStatement* Connection::newCallableStatement ( const nsAReadableString & sql ) [protected, pure virtual]
 

Reimplemented in ConnectionDB2, ConnectionODBC, ConnectionOracle, and ConnectionSybase.

Referenced by prepareCall().

virtual PreparedStatement* Connection::newPreparedStatement ( const nsAReadableString & sql ) [protected, pure virtual]
 

Reimplemented in ConnectionDB2, ConnectionODBC, ConnectionOracle, and ConnectionSybase.

Referenced by prepareStatement().

CallableStatement * Connection::prepareCall ( const nsAReadableString & sql )
 

Definition at line 157 of file Connection.cpp.

PreparedStatement * Connection::prepareStatement ( const nsAReadableString & sql )
 

Definition at line 145 of file Connection.cpp.

Referenced by Transaction::doDelete(), Transaction::doInsert(), Transaction::doSelect(), Report::doSelect(), and Transaction::doUpdate().

void Connection::releaseLock ( ) [protected]
 

called by ConnectionPool.returnConnection() right before it wakes up the threads.

Definition at line 140 of file Connection.cpp.

Referenced by ConnectionPool::returnConnection().

virtual void Connection::rollback ( ) [pure virtual]
 

Reimplemented in ConnectionDB2, ConnectionODBC, ConnectionOracle, and ConnectionSybase.

Referenced by DBPage::rollbackConnection().

void Connection::run ( ) [protected]
 

This is used by ConnectionPool.removeConnection().

It closes all statements and closes the actual JDBC Connection. We implement this in a runnable method so that we can run this in a separate Thread and use a timeout mechanism to avoid deadlock (which was occurring when trying to close a Connection that had a query in progress)

Definition at line 55 of file Connection.cpp.

virtual void Connection::setAutoCommit ( bool state ) [pure virtual]
 

Reimplemented in ConnectionDB2, ConnectionODBC, ConnectionOracle, and ConnectionSybase.

Referenced by ConnectionPool::getConnection().

void Connection::setCatalog ( const nsAReadableString & catalog ) [inline, virtual]
 

Definition at line 66 of file Connection.h.

void Connection::setReadOnly ( bool readOnly ) [inline, virtual]
 

Definition at line 64 of file Connection.h.

void Connection::setTransactionIsolation ( int level ) [inline, virtual]
 

Definition at line 68 of file Connection.h.


Member Data Documentation

ConnectionPool [private]
 

Definition at line 23 of file Connection.h.

mapStringCallableStatement Connection::m_callStmts [private]
 

Definition at line 34 of file Connection.h.

int Connection::m_checkoutCount [private]
 

Definition at line 28 of file Connection.h.

bool Connection::m_free [private]
 

Definition at line 27 of file Connection.h.

long Connection::m_lastAccess [private]
 

Definition at line 26 of file Connection.h.

bool Connection::m_locked [private]
 

Definition at line 25 of file Connection.h.

mapStringPreparedStatement Connection::m_prepStmts [private]
 

Definition at line 31 of file Connection.h.


The documentation for this class was generated from the following files:
Generated at Tue Sep 12 16:29:47 2000 by doxygen1.2.1 written by Dimitri van Heesch, © 1997-2000