#include <SqlGwConnection.h>
Inheritance diagram for SqlGwConnection:
Public Member Functions | |
SqlGwConnection () | |
void | setTxnHandler (GwHandler hdlr) |
GwHandler | getTxnHandler () |
DbRetVal | connect (char *user, char *pass) |
opens connection to the sql engine | |
DbRetVal | disconnect () |
closes connection to the sql engine and releases all the resources | |
DbRetVal | commit () |
Commits active transaction. | |
DbRetVal | rollback () |
Aborts the active transaction. | |
DbRetVal | beginTrans (IsolationLevel isoLevel, TransSyncMode mode=OSYNC) |
Starts a new transaction. | |
void | setAdapter (AbsSqlConnection *conn) |
AbsSqlConnection * | getAdapterConnection () |
DbRetVal | connectCSqlIfNotConnected () |
DbRetVal | connectAdapterIfNotConnected () |
Connection & | getConnObject () |
Data Fields | |
GwHandler | txnHdlr |
TransSyncMode | mode |
Friends | |
class | SqlFactory |
Definition at line 34 of file SqlGwConnection.h.
SqlGwConnection::SqlGwConnection | ( | ) | [inline] |
Definition at line 46 of file SqlGwConnection.h.
References AbsSqlConnection::innerConn, mode, and OSYNC.
DbRetVal SqlGwConnection::beginTrans | ( | IsolationLevel | isoLevel, | |
TransSyncMode | mode = OSYNC | |||
) | [virtual] |
Starts a new transaction.
The previous transaction should be either committed or rollback
before beginTrans is called.
Applications are required to start transaction before they attempt any
database operation.
isoLevel | isolation level. Default is read committed. |
Implements AbsSqlConnection.
Definition at line 49 of file SqlGwConnection.cxx.
References AbsSqlConnection::beginTrans(), CSqlHandler, ErrNoConnection, AbsSqlConnection::innerConn, OK, and txnHdlr.
00050 { 00051 DbRetVal rv = OK; 00052 if (!isAdapterConnected && !isCSqlConnected) return ErrNoConnection; 00053 if (innerConn && isCSqlConnected) rv = innerConn->beginTrans(isoLevel, smode); 00054 if (rv != OK) return rv; 00055 if (adapter && isAdapterConnected) rv = adapter->beginTrans(isoLevel); 00056 //mode = smode; 00057 txnHdlr = CSqlHandler; 00058 return rv; 00059 }
Here is the call graph for this function:
DbRetVal SqlGwConnection::commit | ( | ) | [virtual] |
Commits active transaction.
It makes all the changes made in the current transaction permanent and
it also releases the locks held by the current transaction.
After a transaction commits, application is required to start another
transaction for further database operations.
Implements AbsSqlConnection.
Definition at line 60 of file SqlGwConnection.cxx.
References AdapterHandler, AbsSqlConnection::commit(), CSqlAndAdapterHandler, ErrNoConnection, AbsSqlConnection::innerConn, OK, and txnHdlr.
00061 { 00062 DbRetVal rv = OK; 00063 if (innerConn && isCSqlConnected) 00064 //(txnHdlr == CSqlHandler || txnHdlr == CSqlAndAdapterHandler)) 00065 rv = innerConn->commit(); 00066 if (rv != OK) return rv; 00067 if (adapter && 00068 (txnHdlr == AdapterHandler || txnHdlr == CSqlAndAdapterHandler)) 00069 rv = adapter->commit(); 00070 if (!isAdapterConnected && !isCSqlConnected) return ErrNoConnection; 00071 return rv; 00072 }
Here is the call graph for this function:
DbRetVal SqlGwConnection::connect | ( | char * | user, | |
char * | pass | |||
) | [virtual] |
opens connection to the sql engine
user | username for authentication | |
pass | password for authentication |
Implements AbsSqlConnection.
Definition at line 24 of file SqlGwConnection.cxx.
References AbsSqlConnection::connect(), ErrNoConnection, AbsSqlConnection::innerConn, and OK.
00025 { 00026 isCSqlConnected = false; 00027 isAdapterConnected = false; 00028 strcpy(username, user); 00029 strcpy(password, pass); 00030 DbRetVal rv = OK; 00031 if (innerConn) rv = innerConn->connect(user,pass); 00032 if (rv == OK) isCSqlConnected = true; 00033 if (adapter) rv = adapter->connect(user,pass); 00034 if (rv == OK) isAdapterConnected = true; 00035 if (!isAdapterConnected && !isCSqlConnected) return ErrNoConnection; 00036 return OK; 00037 00038 }
Here is the call graph for this function:
DbRetVal SqlGwConnection::connectAdapterIfNotConnected | ( | ) |
Definition at line 95 of file SqlGwConnection.cxx.
References AbsSqlConnection::connect(), and OK.
00096 { 00097 if (!isAdapterConnected) { 00098 DbRetVal rv = adapter->connect(username, password); 00099 if (rv != OK) return rv; 00100 isAdapterConnected = true; 00101 } 00102 return OK; 00103 }
Here is the call graph for this function:
DbRetVal SqlGwConnection::connectCSqlIfNotConnected | ( | ) |
Definition at line 86 of file SqlGwConnection.cxx.
References AbsSqlConnection::connect(), AbsSqlConnection::innerConn, and OK.
00087 { 00088 if (!isCSqlConnected) { 00089 DbRetVal rv = innerConn->connect(username, password); 00090 if (rv != OK) return rv; 00091 isCSqlConnected = true; 00092 } 00093 return OK; 00094 }
Here is the call graph for this function:
DbRetVal SqlGwConnection::disconnect | ( | ) | [virtual] |
closes connection to the sql engine and releases all the resources
Implements AbsSqlConnection.
Definition at line 39 of file SqlGwConnection.cxx.
References AbsSqlConnection::disconnect(), AbsSqlConnection::innerConn, and OK.
00040 { 00041 DbRetVal rv = OK; 00042 if (innerConn && isCSqlConnected) rv =innerConn->disconnect(); 00043 if (rv != OK) return rv; 00044 if (adapter && isAdapterConnected) rv = adapter->disconnect(); 00045 isCSqlConnected = false; 00046 isAdapterConnected = false; 00047 return rv; 00048 }
Here is the call graph for this function:
AbsSqlConnection* SqlGwConnection::getAdapterConnection | ( | ) | [inline] |
Definition at line 63 of file SqlGwConnection.h.
Referenced by SqlGwStatement::setConnection().
Here is the caller graph for this function:
Connection& SqlGwConnection::getConnObject | ( | ) | [inline, virtual] |
GwHandler SqlGwConnection::getTxnHandler | ( | ) | [inline] |
DbRetVal SqlGwConnection::rollback | ( | ) | [virtual] |
Aborts the active transaction.
undo all the changes made in the current transaction and it also
releases the locks held by the current transaction.
After a transaction rollback, application is required to start another
transaction for further database operations.
Implements AbsSqlConnection.
Definition at line 73 of file SqlGwConnection.cxx.
References AdapterHandler, CSqlAndAdapterHandler, ErrNoConnection, AbsSqlConnection::innerConn, OK, AbsSqlConnection::rollback(), and txnHdlr.
00074 { 00075 DbRetVal rv = OK; 00076 if (innerConn && isCSqlConnected) 00077 //(txnHdlr == CSqlHandler || txnHdlr == CSqlAndAdapterHandler)) 00078 rv = innerConn->rollback(); 00079 if (rv != OK) return rv; 00080 if (adapter && isAdapterConnected && 00081 (txnHdlr == AdapterHandler || txnHdlr == CSqlAndAdapterHandler)) 00082 rv = adapter->rollback(); 00083 if (!isAdapterConnected && !isCSqlConnected) return ErrNoConnection; 00084 return rv; 00085 }
Here is the call graph for this function:
void SqlGwConnection::setAdapter | ( | AbsSqlConnection * | conn | ) | [inline] |
Definition at line 62 of file SqlGwConnection.h.
References conn.
Referenced by SqlFactory::createConnection().
00062 { adapter = conn; }
Here is the caller graph for this function:
void SqlGwConnection::setTxnHandler | ( | GwHandler | hdlr | ) | [inline] |
friend class SqlFactory [friend] |
Definition at line 60 of file SqlGwConnection.h.
Definition at line 44 of file SqlGwConnection.h.
Referenced by beginTrans(), commit(), getTxnHandler(), rollback(), and setTxnHandler().