fintp_udal
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FinTP::ODBCDatabase Class Reference

Derived ODBCDatabase class to implement specific operations for ODBC Databases. More...

#include <ODBCDatabase.h>

Inheritance diagram for FinTP::ODBCDatabase:

Public Member Functions

 ODBCDatabase ()
 
virtual ~ODBCDatabase ()
 
virtual void BeginTransaction (const bool readonly)
 Starts a transaction. More...
 
virtual void EndTransaction (const TransactionType::TRANSACTION_TYPE transactionType, const bool throwOnError)
 Ends a transaction. More...
 
void Connect (const ConnectionString &connectionString)
 Connects using the given connection string. More...
 
void Disconnect ()
 Disconnects and release connection resources. More...
 
virtual bool IsConnected ()
 Query if Database instance is connected. More...
 
void ExecuteNonQuery (const DataCommand::COMMAND_TYPE commType, const string &stringStatement, bool onCursor)
 Execute NonQuery SQL statements or stored procedures ( without params ) More...
 
void ExecuteNonQueryCached (const DataCommand::COMMAND_TYPE commType, const string &stringStatement, bool onCursor)
 Execute NonQueryCached SQL statements or stored procedures ( without params ) and use caching. More...
 
void ExecuteNonQuery (const DataCommand::COMMAND_TYPE commType, const string &stringStatement, const ParametersVector &vectorOfParameters, bool onCursor)
 Execute NonQuery SQL statements or stored procedures ( with params ) More...
 
void ExecuteNonQueryCached (const DataCommand::COMMAND_TYPE commType, const string &stringStatement, const ParametersVector &vectorOfParameters, bool onCursor)
 Execute NonQueryCached SQL statements or stored procedures ( with params ) and use caching. More...
 
DataSetExecuteQuery (const DataCommand::COMMAND_TYPE commType, const string &stringStatement, bool onCursor, const unsigned int fetchRows)
 Execute Query SQL statements ( without params ) More...
 
DataSetExecuteQuery (const DataCommand::COMMAND_TYPE commType, const string &stringStatement, const ParametersVector &vectorOfParameters, bool onCursor, const unsigned int fetchRows)
 Execute Query SQL statements ( with params ) More...
 
DataSetExecuteQueryCached (const DataCommand::COMMAND_TYPE commType, const string &stringStatement, const bool onCursor, const unsigned int fetchRows)
 Query SQL statements ( without params ) and use caching More...
 
DataSetExecuteQueryCached (const DataCommand::COMMAND_TYPE commType, const string &stringStatement, const ParametersVector &vectorOfParameters, const bool onCursor, const unsigned int fetchRows)
 Execute Query SQL statements ( with params ) and use caching. More...
 
void ReleaseCursor (const bool checkConn)
 If onCursor=true is passed to ExecuteQuery methods, a client is required to use these methods to release cursor resources. More...
 
void RewindCursor ()
 Rewind cursor to the first position. More...
 
bool CursorHeld () const
 Determines if we can hold the cursor. More...
 
- Public Member Functions inherited from FinTP::Database
 Database ()
 
virtual ~Database ()
 
void BeginTransaction ()
 
void EndTransaction (const TransactionType::TRANSACTION_TYPE transactionType)
 
void ExecuteNonQuery (const DataCommand::COMMAND_TYPE commandType, const string &stringStatement)
 
void ExecuteNonQueryCached (const DataCommand::COMMAND_TYPE commandType, const string &stringStatement)
 
void ExecuteNonQuery (const DataCommand::COMMAND_TYPE commandType, const string &stringStatement, const ParametersVector &vectorOfParameters)
 
void ExecuteNonQueryCached (const DataCommand::COMMAND_TYPE commandType, const string &stringStatement, const ParametersVector &vectorOfParameters)
 
DataSetExecuteQuery (const DataCommand::COMMAND_TYPE commandType, const string &stringStatement, bool holdCursor)
 
DataSetExecuteQuery (const DataCommand::COMMAND_TYPE commandType, const string &stringStatement)
 
DataSetExecuteQueryCached (const DataCommand::COMMAND_TYPE commandType, const string &stringStatement, bool holdCursor)
 
DataSetExecuteQueryCached (const DataCommand::COMMAND_TYPE commandType, const string &stringStatement)
 
DataSetExecuteQuery (const DataCommand::COMMAND_TYPE commandType, const string &stringStatement, const ParametersVector &vectorOfParameters, bool holdCursor)
 
DataSetExecuteQuery (const DataCommand::COMMAND_TYPE commandType, const string &stringStatement, const ParametersVector &vectorOfParameters)
 
DataSetExecuteQueryCached (const DataCommand::COMMAND_TYPE commandType, const string &stringStatement, const ParametersVector &vectorOfParameters, bool holdCursor)
 
DataSetExecuteQueryCached (const DataCommand::COMMAND_TYPE commandType, const string &stringStatement, const ParametersVector &vectorOfParameters)
 
void ReleaseCursor ()
 
int getLastNumberofAffectedRows () const
 

Protected Member Functions

bool isEnvAllocated () const
 
SQLRETURN AllocateEnv ()
 
bool isDbcAllocated () const
 
void BindParams (const ParametersVector &vectorOfParameters, SQLHANDLE *statementHandle=NULL, const unsigned int startIndex=1)
 
DataSetinnerExecuteCommand (const DataCommand &command, const ParametersVector &vectorOfParameters, const bool useCursor=false, const unsigned int fetchRows=0)
 
DataSetexecuteQuery (DataCommand &command, const bool isCommandCached, SQLHANDLE *statementHandle, const bool useCursor, const unsigned int fetchRows=0)
 
DataSetgetDataSet (DataCommand &command, const bool isCommandCached, SQLHANDLE *statementHandle, const bool useCursor, const unsigned int fetchRows=0)
 
void executeNonQuery (DataCommand &command, const bool isCommandCached, SQLHANDLE *statementHandle, const bool useCursor)
 
virtual string getErrorInformation (SQLSMALLINT htype, SQLHANDLE handle)
 
virtual void setSpecificConnAttr ()
 
virtual void setSpecificEnvAttr ()
 
virtual string callFormating (const string &statementString, const ParametersVector &vectorOfParameters)
 

Static Protected Member Functions

static int getODBCTransactionType (TransactionType::TRANSACTION_TYPE type)
 

Protected Attributes

SQLHANDLE m_Henv
 
bool m_HenvAllocated
 
bool m_IsConnected
 
SQLHANDLE m_Hdbc
 
bool m_HdbcAllocated
 
SQLHANDLE m_Hstmt
 
SQLHANDLE m_HoldCursorHandle
 
string m_HoldCursorName
 
bool m_HoldCursorInvoked
 
- Protected Attributes inherited from FinTP::Database
CacheManager< string, DataCommandm_StatementCache
 Collection to hold already executed Command instances. More...
 
string m_LastErrorCode
 The last error code returned from command execution. More...
 
unsigned int m_LastNumberofAffectedRows
 The number of updates last command performed. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from FinTP::Database
static void DisplayDataSet (const DataSet *theDataSet)
 Utility method used to pretty print DataSet objects. More...
 
static
XERCES_CPP_NAMESPACE_QUALIFIER
DOMDocument * 
ConvertToXML (const DataSet *theDataSet, const bool doTrimm=true)
 Utility method that converts DataSet parameter objects to following XML format: <TableName> <Record> <Column_Name_n>Column_Value_n<Column_Name_n> </Record> </TableName> More...
 
- Static Public Attributes inherited from FinTP::Database
static string DateFormat = "DD.MM.YYYY"
 Used to convert a date/timestamp column to a string format database specific formats. More...
 
static string TimestampFormat = "DD.MM.YYYY HH:MI"
 

Detailed Description

Derived ODBCDatabase class to implement specific operations for ODBC Databases.

  1. First a new ODBCDatabase instace is created
  2. Then, the client can create a new transaction by calling BeginTransaction(readonly) method
  3. Transactions comprise one ore more calls to "ExecuteQuery" methods. Every database query is mapped to a Command instance and can be cached in m_StatementCache member of Database instance
  4. A transaction ends when the client calls EndTransaction(transactionType) performing commit or rollback on current transaction
  5. The database connection is released when Disconect() is called.

Database declare two types of "ExecuteQuery" methods

  • ExecuteQuery - Create a DataCommand from passed parameters and execute it
  • ExecuteQueryChached - Additionally, attempts to retrieve the params and resultset columns from DataCommand cache or adds them if not available

Database, define four library specific exception types to be used by its implementations

Constructor & Destructor Documentation

ODBCDatabase::ODBCDatabase ( )
ODBCDatabase::~ODBCDatabase ( )
virtual

Member Function Documentation

SQLRETURN ODBCDatabase::AllocateEnv ( )
protected
void ODBCDatabase::BeginTransaction ( const bool  readonly)
virtual

Starts a transaction.

Parameters
readonly= true if no Inserts/Updates are intended

Implements FinTP::Database.

Reimplemented in FinTP::InformixDatabase, and FinTP::SqlServerDatabase.

void ODBCDatabase::BindParams ( const ParametersVector vectorOfParameters,
SQLHANDLE *  statementHandle = NULL,
const unsigned int  startIndex = 1 
)
protected
string ODBCDatabase::callFormating ( const string &  statementString,
const ParametersVector vectorOfParameters 
)
protectedvirtual
void ODBCDatabase::Connect ( const ConnectionString connectionString)
virtual

Connects using the given connection string.

Parameters
connectionString.Connection information nedeed to connect to DBMS.

Implements FinTP::Database.

bool FinTP::ODBCDatabase::CursorHeld ( ) const
inlinevirtual

Determines if we can hold the cursor.

Returns
true if cursor is held , false if not.

Reimplemented from FinTP::Database.

void ODBCDatabase::Disconnect ( )
virtual

Disconnects and release connection resources.

Implements FinTP::Database.

void ODBCDatabase::EndTransaction ( const TransactionType::TRANSACTION_TYPE  transactionType,
const bool  throwOnError 
)
virtual

Ends a transaction.

Parameters
transactionTypeTransactionType option to close transaction
throwOnErrorBool flag to inhibit exception throwing on error.
Note
why wish not to throw exception

Implements FinTP::Database.

Reimplemented in FinTP::InformixDatabase, and FinTP::SqlServerDatabase.

void FinTP::ODBCDatabase::ExecuteNonQuery ( const DataCommand::COMMAND_TYPE  commType,
const string &  stringStatement,
bool  onCursor 
)
inlinevirtual

Execute NonQuery SQL statements or stored procedures ( without params )

Parameters
commTypetype COMMAND_TYPE. The command type.
stringStatementtype string. The statement.
onCursortype bool. Determine if the function will use an Oracle cursor to iterate through the results.

Implements FinTP::Database.

void FinTP::ODBCDatabase::ExecuteNonQuery ( const DataCommand::COMMAND_TYPE  commType,
const string &  stringStatement,
const ParametersVector vectorOfParameters,
bool  onCursor 
)
inlinevirtual

Execute NonQuery SQL statements or stored procedures ( with params )

Parameters
commTypetype COMMAND_TYPE. The command type .
stringStatementtype string. The statement.
vectorOfParameterstype ParametersVector. The vector of parameters. Used when multiple parameters are needed.
onCursortype bool. Determine if the function will use an Oracle cursor to iterate through the results.

Implements FinTP::Database.

void ODBCDatabase::executeNonQuery ( DataCommand command,
const bool  isCommandCached,
SQLHANDLE *  statementHandle,
const bool  useCursor 
)
protected
void FinTP::ODBCDatabase::ExecuteNonQueryCached ( const DataCommand::COMMAND_TYPE  commType,
const string &  stringStatement,
bool  onCursor 
)
inlinevirtual

Execute NonQueryCached SQL statements or stored procedures ( without params ) and use caching.

Parameters
commTypetype COMMAND_TYPE. The command type
stringStatementtype string. The statement.
onCursortype bool. Determine if the function will use an Oracle cursor to iterate through the results.

Implements FinTP::Database.

void FinTP::ODBCDatabase::ExecuteNonQueryCached ( const DataCommand::COMMAND_TYPE  commType,
const string &  stringStatement,
const ParametersVector vectorOfParameters,
bool  onCursor 
)
inlinevirtual

Execute NonQueryCached SQL statements or stored procedures ( with params ) and use caching.

Parameters
commTypetype COMMAND_TYPE. The command type.
stringStatementtype string. The statement.
vectorOfParameterstype ParametersVector. The vector of parameters. Used when multiple parameters are needed.
onCursortype bool. Determine if the function will use an Oracle cursor to iterate through the results.

Implements FinTP::Database.

DataSet* FinTP::ODBCDatabase::ExecuteQuery ( const DataCommand::COMMAND_TYPE  commType,
const string &  stringStatement,
bool  onCursor,
const unsigned int  fetchRows 
)
inlinevirtual

Execute Query SQL statements ( without params )

Parameters
commTypetype COMMAND_TYPE. The command type.
stringStatementtype string. The statement.
onCursortype bool. Determine if the function will use an Oracle cursor to iterate through the results.
fetchRowstype int. The row number used in where clause.

Implements FinTP::Database.

Reimplemented in FinTP::PostgresDatabase.

DataSet* FinTP::ODBCDatabase::ExecuteQuery ( const DataCommand::COMMAND_TYPE  commType,
const string &  stringStatement,
const ParametersVector vectorOfParameters,
bool  onCursor,
const unsigned int  fetchRows 
)
inlinevirtual

Execute Query SQL statements ( with params )

Parameters
commTypetype COMMAND_TYPE. The command type.
stringStatementtype string. The statement.
vectorOfParameterstype ParametersVector. The vector of parameters. Used when multiple parameters are needed.
onCursortype bool. Determine if the function will use a cursor to iterate through the results.
fetchRowstype int. The row number used in where clause.

Implements FinTP::Database.

Reimplemented in FinTP::PostgresDatabase.

DataSet * ODBCDatabase::executeQuery ( DataCommand command,
const bool  isCommandCached,
SQLHANDLE *  statementHandle,
const bool  useCursor,
const unsigned int  fetchRows = 0 
)
protected
DataSet* FinTP::ODBCDatabase::ExecuteQueryCached ( const DataCommand::COMMAND_TYPE  commType,
const string &  stringStatement,
const bool  onCursor,
const unsigned int  fetchRows 
)
inlinevirtual

Query SQL statements ( without params ) and use caching

Parameters
commTypetype COMMAND_TYPE. The command type.
stringStatementtype string. The statement.
onCursortype bool. Determine if the function will use a cursor to iterate through the results.
fetchRowstype int. The row number used in where clause.

Implements FinTP::Database.

Reimplemented in FinTP::PostgresDatabase.

DataSet* FinTP::ODBCDatabase::ExecuteQueryCached ( const DataCommand::COMMAND_TYPE  commType,
const string &  stringStatement,
const ParametersVector vectorOfParameters,
const bool  onCursor,
const unsigned int  fetchRows 
)
inlinevirtual

Execute Query SQL statements ( with params ) and use caching.

Parameters
commTypetype COMMAND_TYPE. The command type.
stringStatementtype string. The statement.
vectorOfParameterstype ParametersVector. The vector of parameters. Used when multiple parameters are needed.
onCursortype bool. Determine if the function will use a cursor to iterate through the results.
fetchRowstype int. The row number used in where clause.

Implements FinTP::Database.

Reimplemented in FinTP::PostgresDatabase.

DataSet * ODBCDatabase::getDataSet ( DataCommand command,
const bool  isCommandCached,
SQLHANDLE *  statementHandle,
const bool  useCursor,
const unsigned int  fetchRows = 0 
)
protected
string ODBCDatabase::getErrorInformation ( SQLSMALLINT  htype,
SQLHANDLE  handle 
)
protectedvirtual

Reimplemented in FinTP::InformixDatabase.

int ODBCDatabase::getODBCTransactionType ( TransactionType::TRANSACTION_TYPE  type)
staticprotected
DataSet * ODBCDatabase::innerExecuteCommand ( const DataCommand command,
const ParametersVector vectorOfParameters,
const bool  useCursor = false,
const unsigned int  fetchRows = 0 
)
protected
virtual bool FinTP::ODBCDatabase::IsConnected ( )
inlinevirtual

Query if Database instance is connected.

Returns
true if connected, false if not.

Implements FinTP::Database.

Reimplemented in FinTP::InformixDatabase.

bool FinTP::ODBCDatabase::isDbcAllocated ( ) const
inlineprotected
bool FinTP::ODBCDatabase::isEnvAllocated ( ) const
inlineprotected
void ODBCDatabase::ReleaseCursor ( const bool  checkConn)
virtual

If onCursor=true is passed to ExecuteQuery methods, a client is required to use these methods to release cursor resources.

Parameters
checkConntrue to check connection.

Implements FinTP::Database.

void ODBCDatabase::RewindCursor ( )
virtual

Rewind cursor to the first position.

Implements FinTP::Database.

virtual void FinTP::ODBCDatabase::setSpecificConnAttr ( )
inlineprotectedvirtual
void ODBCDatabase::setSpecificEnvAttr ( )
protectedvirtual

Member Data Documentation

SQLHANDLE FinTP::ODBCDatabase::m_Hdbc
protected
bool FinTP::ODBCDatabase::m_HdbcAllocated
protected
SQLHANDLE FinTP::ODBCDatabase::m_Henv
protected
bool FinTP::ODBCDatabase::m_HenvAllocated
protected
SQLHANDLE FinTP::ODBCDatabase::m_HoldCursorHandle
protected
bool FinTP::ODBCDatabase::m_HoldCursorInvoked
protected
string FinTP::ODBCDatabase::m_HoldCursorName
protected
SQLHANDLE FinTP::ODBCDatabase::m_Hstmt
protected
bool FinTP::ODBCDatabase::m_IsConnected
protected

The documentation for this class was generated from the following files: