Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

Connection Class Reference

Abstract class representing connection to a database. More...

#include <cConnection.h>

Inheritance diagram for Connection:

Inheritance graph
[legend]
Collaboration diagram for Connection:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 ~Connection ()
virtual bool Sql (const char *sqlCommand)
virtual bool Commit ()
virtual bool Rollback ()
virtual bool Savepoint (const char *name)
virtual bool RollbackToSavepoint (const char *name)
virtual bool Disconnect ()
virtual bool Abort ()
virtual bool Autocommit (bool ac)=0
virtual class Cursor_GetNewCursor ()=0
virtual Connectionoperator<< (const char *SqlCommand)
Connectionoperator<< (const class Cmd &Command)
bool operator== (const class Connection &DbConn) const
bool operator!= (const class Connection &DbConn) const
virtual enum UpdatingStrategy CurrentUpdatingStrategy () const
virtual bool SetUpdatingStrategy (enum UpdatingStrategy anUpdateStrategy)
virtual enum WaitingStrategy CurrentWaitingStrategy () const
virtual bool SetWaitingStrategy (enum WaitingStrategy aWaitingStrategy)
virtual enum LockingStrategy CurrentLockingStrategy () const
virtual bool SetLockingStrategy (enum LockingStrategy aLockingStrategy)
virtual enum ReadingStrategy CurrentReadingStrategy () const
virtual bool SetReadingStrategy (enum ReadingStrategy aReadingStrategy)
virtual bool _Open ()
virtual bool _Prepare (const char *SqlCommand)
virtual bool _PreExecBind (const char *varName, const int pos, const void *varAddr, const int varLen, const IopcDataType varType, const bool null=false)
virtual bool _Execute ()
virtual bool _PreFetchBind (const int position, const void *varAddr, const int varLen, const IopcDataType varType, bool *null=NULL)
virtual bool _FetchNext ()
virtual bool _FetchPrev ()
virtual bool _Close ()

Protected Member Functions

 Connection (class Database *DB, const char *UserName, const char *Password, const int LocHandle, const int GlobHandle)
virtual bool _Sql (const char *sqlCommand)
virtual bool _Commit ()=0
virtual bool _Rollback ()=0
virtual bool _Savepoint (const char *name)=0
virtual bool _RollbackToSavepoint (const char *name)=0
virtual bool _NextOID (long int &nxtoid, long int &nxtsn)=0
virtual bool _NextSN (long int curoid, long int &nxtsn)=0
char * _GetUserName ()
char * _GetPassword ()
virtual bool _PreExecBind (const char *VarName, const void *VarAddr, const int VarLen, const char VarType, short *VarInd=NULL)
virtual bool _PreFetchBind (const int Position, const void *VarAddr, const int VarLen, const char VarType, short *VarInd=NULL)

Protected Attributes

unsigned short _Strategies
char * _UserName
char * _Password
Database_Database
int _Handle
int _LocalHandle
Cursor_DefaultCursor

Detailed Description

Abstract class representing connection to a database.

The only "correct" instantiable descendant of this class is currently class Oracle8iConnection. If you want to implement support for another database please have a look at that class.

This class was nearly undocumented in POLiTe - a few of old comments can be found in source code - not in doxygen. I (Josef Troch) have documented all "interface" (i.e. pure virtual) functions of this class and also put a few words to other important methods. Remaining members were left undocumented.

If macro ALLOW_DIRECT_SQL_SELECTS is defined, functions _Open(), _Prepare(), _PreExecBind(), _Execute(), _PreFetchBind(), _FetchNext(), _FetchPrev() and _Close() are public and user can use them for direct SQL access to the database. By default the macro is not defined.

Methods of this class returns true if OK, false otherwise.

See also:
Database, DatabaseSqlStatements, Cursor


Constructor & Destructor Documentation

Connection::Connection class Database DB,
const char *  UserName,
const char *  Password,
const int  LocHandle,
const int  GlobHandle
[protected]
 

Connection::~Connection  ) 
 


Member Function Documentation

bool Connection::_Sql const char *  sqlCommand  )  [protected, virtual]
 

Processes SQL command (sqlCommand) - calls _Open(), _Prepare(), _Execute() and _Close() for it.

Parameters:
sqlCommand SQL statement to be processed.

Reimplemented in OracleConnection.

virtual bool Connection::_Commit  )  [protected, pure virtual]
 

Commits actual transaction.

Implemented in OracleConnection, and Oracle8iConnection.

virtual bool Connection::_Rollback  )  [protected, pure virtual]
 

Performs rollback of actual transaction.

Implemented in OracleConnection, and Oracle8iConnection.

virtual bool Connection::_Savepoint const char *  name  )  [protected, pure virtual]
 

Creates savepoint with given name (name).

If your database doesn't support savepoints, feel free to make fake implementation of this function.

Implemented in OracleConnection, and Oracle8iConnection.

virtual bool Connection::_RollbackToSavepoint const char *  name  )  [protected, pure virtual]
 

Performs rollback to savepoint with given name (name).

If your database doesn't support savepoints, feel free to make fake implementation of this function.

Implemented in OracleConnection, and Oracle8iConnection.

virtual bool Connection::_NextOID long int &  nxtoid,
long int &  nxtsn
[protected, pure virtual]
 

Generates new OID and Serial Number for a new object.

Obsolete function used by POLiTe-style persistent classes. IopcPersistentObject ancestors don't use this function, so you can make fake implementation of this function if you don't need to support POLiTe-style persistent classes.

Parameters:
nxtoid Resulting OID.
nxtsn Resulting Serial Number

Implemented in OracleConnection.

virtual bool Connection::_NextSN long int  curoid,
long int &  nxtsn
[protected, pure virtual]
 

Generates new Serial Number for object with given OID.

Obsolete function used by POLiTe-style persistent classes. IopcPersistentObject ancestors don't use this function, so you can make fake implementation of this function if you don't need to support POLiTe-style persistent classes.

Parameters:
curoid The OID.
nxtsn Resulting Serial Number

Implemented in OracleConnection.

bool Connection::Sql const char *  sqlCommand  )  [virtual]
 

Updates all objects in cache, then calls _Sql().

Parameters:
sqlCommand SQL statement to be processed

Reimplemented in OracleConnection.

bool Connection::Commit  )  [virtual]
 

Saves modified objects to the database, then commits actual transaction.

Reimplemented in OracleConnection.

bool Connection::Rollback  )  [virtual]
 

Performs rollback of actual transaction, then removes all persistent objects from the memory.

Reimplemented in OracleConnection.

bool Connection::Savepoint const char *  name  )  [virtual]
 

Saves modified objects to the database, then creates savepoint.

Parameters:
name Name of savepoint to be created.

Reimplemented in OracleConnection.

bool Connection::RollbackToSavepoint const char *  name  )  [virtual]
 

Performs rollback to savepoint, then destroys all data in memory.

Parameters:
name Name of savepoint to rollback to.

Reimplemented in OracleConnection.

bool Connection::Disconnect  )  [virtual]
 

Commits actual transaction, then disconnects from database.

Reimplemented in OracleConnection, and Oracle8iConnection.

bool Connection::Abort  )  [virtual]
 

Performs rollback of actual transaction, then disconnect from database.

Reimplemented in OracleConnection, and Oracle8iConnection.

virtual bool Connection::Autocommit bool  ac  )  [pure virtual]
 

Turns on / off autocommit (automatic commit of every SQL data manipulation statement).

Parameters:
ac 1 to turn autocommit on, 0 to turn it off.

Implemented in OracleConnection, and Oracle8iConnection.

virtual class Cursor* Connection::_GetNewCursor  )  [pure virtual]
 

Creates and returns new cursor.

Implemented in OracleConnection, and Oracle8iConnection.

Connection & Connection::operator<< const char *  SqlCommand  )  [virtual]
 

Connection & Connection::operator<< const class Cmd Command  ) 
 

bool Connection::operator== const class Connection DbConn  )  const
 

bool Connection::operator!= const class Connection DbConn  )  const
 

virtual enum UpdatingStrategy Connection::CurrentUpdatingStrategy  )  const [inline, virtual]
 

bool Connection::SetUpdatingStrategy enum UpdatingStrategy  anUpdateStrategy  )  [virtual]
 

virtual enum WaitingStrategy Connection::CurrentWaitingStrategy  )  const [inline, virtual]
 

bool Connection::SetWaitingStrategy enum WaitingStrategy  aWaitingStrategy  )  [virtual]
 

virtual enum LockingStrategy Connection::CurrentLockingStrategy  )  const [inline, virtual]
 

bool Connection::SetLockingStrategy enum LockingStrategy  aLockingStrategy  )  [virtual]
 

virtual enum ReadingStrategy Connection::CurrentReadingStrategy  )  const [inline, virtual]
 

bool Connection::SetReadingStrategy enum ReadingStrategy  aReadingStrategy  )  [virtual]
 

char* Connection::_GetUserName  )  [inline, protected]
 

char* Connection::_GetPassword  )  [inline, protected]
 

bool Connection::_Open  )  [virtual]
 

Opens default cursor

See also:
_DefaultCursor, Cursor::_Open()

bool Connection::_Prepare const char *  SqlCommand  )  [virtual]
 

Prepares sqlCommand to be executed in database using default cursor.

See also:
_DefaultCursor, Cursor::_Prepare()

bool Connection::_PreExecBind const char *  varName,
const int  pos,
const void *  varAddr,
const int  varLen,
const IopcDataType  varType,
const bool  null = false
[virtual]
 

Binds an input variable using default cursor. If varName is not NULL variable is bound by name (varName), if it is NULL, variable is bound by position (pos). This function is called once for every input variable in SQL statement (statement must have been already prepared) -> typically more than once per statement.

Parameter description can be found in documentation of Cursor::_PreExecBind(const char *,const int,const void *,const int,const IopcDataType,bool).

Note:
This is new version of _PreExecBind() added by Josef Troch.
See also:
_DefaultCursor, Cursor::_PreExecBind(const char *,const int,const void *,const int,const IopcDataType,bool)

bool Connection::_Execute  )  [virtual]
 

Using default cursor executes SQL statement, that has been already prepared (see _Prepare()) and its input variables (if any) have been bound (see _PreExecBind()).

See also:
_DefaultCursor, Cursor::_Execute()

bool Connection::_PreFetchBind const int  position,
const void *  varAddr,
const int  varLen,
const IopcDataType  varType,
bool *  null = NULL
[virtual]
 

Binds an output variable using default cursor. (_Execute() must be called before first call to this function). This function is called once for every output variable in SQL statement -> typically more than once per statement.

Parameter description can be found in documentation of Cursor::_PreFetchBind(const int,const void *,const int,const IopcDataType,bool *)

Note:
This is new version of _PreFetchBind() added by Josef Troch.
See also:
_DefaultCursor, Cursor::_PreFetchBind(const int,const void *,const int,const IopcDataType,bool *)

bool Connection::_FetchNext  )  [virtual]
 

Fetches next row using default cursor. Appropriate SQL statement must have been already executed and its output variables have been bound.

See also:
_DefaultCursor, Cursor::_FetchNext()

bool Connection::_FetchPrev  )  [virtual]
 

Fetches previous row using default cursor. Appropriate SQL statement must have been already executed and its output variables must have been bound.

If the database doesn't support this functionality, throws ObjLibException_NotSupported.

See also:
_DefaultCursor, Cursor::_FetchPrev()

bool Connection::_Close  )  [virtual]
 

Closes the default cursor.

See also:
_DefaultCursor, Cursor::_Open()

bool Connection::_PreExecBind const char *  VarName,
const void *  VarAddr,
const int  VarLen,
const char  VarType,
short *  VarInd = NULL
[protected, virtual]
 

Obsolete version of _PreExecBind() used by POLiTe-style persistent classes. . Use _PreExecBind(const char *,const int,const void *,const int,const IopcDataType,bool) instead.

Parameter description can be found in documentation of Cursor::_PreExecBind(const char *,const void *,const int,const char, short *).

bool Connection::_PreFetchBind const int  Position,
const void *  VarAddr,
const int  VarLen,
const char  VarType,
short *  VarInd = NULL
[protected, virtual]
 

Obsolete version of _PreFetchBind() used by POLiTe-style persistent classes. . Use _PreFetchBind(const int,const void *,const int,const IopcDataType,bool *) instead.

Parameter description can be found in documentation of Cursor::_PreFetchBind(const int,const void *,const int,const char, short *).


Member Data Documentation

unsigned short Connection::_Strategies [protected]
 

char* Connection::_UserName [protected]
 

char* Connection::_Password [protected]
 

class Database* Connection::_Database [protected]
 

int Connection::_Handle [protected]
 

int Connection::_LocalHandle [protected]
 

class Cursor* Connection::_DefaultCursor [protected]
 

Default cursor.


The documentation for this class was generated from the following files:
Generated on Wed Aug 11 22:35:23 2004 for IOPC by Doxygen 1.3.6