1 /***************************************************************************
3 * Copyright (C) Lakshya Solutions Ltd. All rights reserved. *
5 ***************************************************************************/
6 #ifndef ABSSQLCONNECTION_H
7 #define ABSSQLCONNECTION_H
15 char tableName
[IDENTIFIER_LENGTH
];
16 CachedTable() { tableName
[0] = '\0'; }
30 * @class AbsSqlConnection
32 * \brief Represents a database connection to sql engine.
34 * It represents the database connection to the sql engine.\n
35 * All database operations shall be done within the context of the connection.\n
36 * Application should first create object of this class to accessing the database\n
38 * Each connection has only one active transaction at any given point of time, all \n
39 * operations which happen using this connection object will be done as part of that \n
43 * SERIALIZABLE isolation level is not supported. \n
45 class AbsSqlConnection
48 AbsSqlConnection
*innerConn
;
50 void setInnerConnection(AbsSqlConnection
*conn
) { innerConn
= conn
; }
51 AbsSqlConnection
* getInnerConnection() { return innerConn
; }
52 virtual Connection
& getConnObject() =0;
54 /** opens connection to the sql engine
55 * @param user username for authentication
56 * @param pass password for authentication
59 virtual DbRetVal
connect (char *user
, char * pass
) =0;
61 /** closes connection to the sql engine and releases all the resources
64 virtual DbRetVal
disconnect () = 0;
66 /** Commits active transaction. \n
67 * It makes all the changes made in the current transaction permanent and \n
68 * it also releases the locks held by the current transaction.\n
69 * After a transaction commits, application is required to start another \n
70 * transaction for further database operations.\n
73 virtual DbRetVal
commit() = 0;
75 /** Aborts the active transaction.\n
76 * undo all the changes made in the current transaction and it also \n
77 * releases the locks held by the current transaction.\n
78 * After a transaction rollback, application is required to start another \n
79 * transaction for further database operations.\n
82 virtual DbRetVal
rollback() = 0;
84 /** Starts a new transaction.\n
85 * The previous transaction should be either committed or rollback \n
86 * before beginTrans is called. \n
87 * Applications are required to start transaction before they attempt any \n
88 * database operation.\n
89 * @param isoLevel isolation level. Default is read committed.
92 virtual DbRetVal
beginTrans (IsolationLevel isoLevel
= READ_COMMITTED
,
93 TransSyncMode mode
= OSYNC
) = 0;
94 virtual ~AbsSqlConnection()
96 if (innerConn
) { delete innerConn
; innerConn
= NULL
; }
98 virtual void display()
100 if (innerConn
) innerConn
->display();