Public Member Functions | |
| DbRetVal | open (const char *username, const char *password) |
| opens connection to the database | |
| DbRetVal | close () |
| closes connection to the database and releases all the resources | |
| DatabaseManager * | getDatabaseManager () |
| gets the database manager object. | |
| UserManager * | getUserManager () |
| gets the user manager object. | |
| DbRetVal | startTransaction (IsolationLevel level=READ_COMMITTED) |
| Starts a transaction. | |
| DbRetVal | commit () |
| Commits active transaction. | |
| DbRetVal | rollback () |
| Aborts the active transaction. | |
All database operations shall be done within the context of the connection.
Application should first create object of this class for accessing the database.
Each connection has only one active transaction at any given point of time, all
operations which happen using this connection object will be done as part of that
transaction.
Functionality:
1.Connection Management (connect and disconnect)
2.Transaction Management (start, commit, abort)
3.Provides getter methods for database manager and user manager
4.Isolation Level support. REPEATABLE READ,
READ COMMITTED and READ UNCOMMITTED isolation levels
Note:
SERIALIZABLE isolation level is not supported.
| DbRetVal Connection::close | ( | ) |
| DbRetVal Connection::commit | ( | ) |
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.
| DatabaseManager* Connection::getDatabaseManager | ( | ) |
| UserManager* Connection::getUserManager | ( | ) |
| DbRetVal Connection::open | ( | const char * | username, | |
| const char * | password | |||
| ) |
opens connection to the database
| username | username for authentication | |
| password | password for authentication |
| DbRetVal Connection::rollback | ( | ) |
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.
| DbRetVal Connection::startTransaction | ( | IsolationLevel | level = READ_COMMITTED |
) |
Starts a transaction.
The previous transaction should be either committed or rollback
before startTransaction is called.
Application are required to start transaction before they attempt any
database operation.