1 /***************************************************************************
2 * Copyright (C) 2007 by Prabakaran Thirumalai *
3 * praba_tuty@yahoo.com *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
20 #ifndef ABSSQLCONNECTION_H
21 #define ABSSQLCONNECTION_H
26 char tableName
[IDENTIFIER_LENGTH
];
40 * @class AbsSqlConnection
42 * \brief Represents a database connection to sql engine.
44 * It represents the database connection to the sql engine.\n
45 * All database operations shall be done within the context of the connection.\n
46 * Application should first create object of this class to accessing the database\n
48 * Each connection has only one active transaction at any given point of time, all \n
49 * operations which happen using this connection object will be done as part of that \n
53 * SERIALIZABLE isolation level is not supported. \n
55 class AbsSqlConnection
58 AbsSqlConnection
*innerConn
;
60 void setInnerConnection(AbsSqlConnection
*conn
) { innerConn
= conn
; }
61 AbsSqlConnection
* getInnerConnection() { return innerConn
; }
62 virtual Connection
& getConnObject() =0;
64 /** opens connection to the sql engine
65 * @param user username for authentication
66 * @param pass password for authentication
69 virtual DbRetVal
connect (char *user
, char * pass
) =0;
71 /** closes connection to the sql engine and releases all the resources
74 virtual DbRetVal
disconnect () = 0;
76 /** Commits active transaction. \n
77 * It makes all the changes made in the current transaction permanent and \n
78 * it also releases the locks held by the current transaction.\n
79 * After a transaction commits, application is required to start another \n
80 * transaction for further database operations.\n
83 virtual DbRetVal
commit() = 0;
85 /** Aborts the active transaction.\n
86 * undo all the changes made in the current transaction and it also \n
87 * releases the locks held by the current transaction.\n
88 * After a transaction rollback, application is required to start another \n
89 * transaction for further database operations.\n
92 virtual DbRetVal
rollback() = 0;
94 /** Starts a new transaction.\n
95 * The previous transaction should be either committed or rollback \n
96 * before beginTrans is called. \n
97 * Applications are required to start transaction before they attempt any \n
98 * database operation.\n
99 * @param isoLevel isolation level. Default is read committed.
102 virtual DbRetVal
beginTrans (IsolationLevel isoLevel
= READ_COMMITTED
,
103 TransSyncMode mode
= OSYNC
) = 0;
104 virtual ~AbsSqlConnection(){}