fixing compilation error
[csql.git] / include / AbsSqlConnection.h
bloba0fc3ac488c2436efbe6abe181ca9c5793d0ff67
1 /***************************************************************************
2 * Copyright (C) 2007 by Prabakaran Thirumalai *
3 * praba_tuty@yahoo.com *
4 * *
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. *
9 * *
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. *
14 * *
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
22 #include<CSql.h>
24 enum TransSyncMode {
25 OSYNC=1,
26 ASYNC=2,
27 OASYNC=3
30 enum TableSyncMode {
31 TABLE_OSYNC=1,
32 TABLE_ASYNC=2
34 /**
35 * @class AbsSqlConnection
37 * \brief Represents a database connection to sql engine.
39 * It represents the database connection to the sql engine.\n
40 * All database operations shall be done within the context of the connection.\n
41 * Application should first create object of this class to accessing the database\n
42 * through SQL Engine.
43 * Each connection has only one active transaction at any given point of time, all \n
44 * operations which happen using this connection object will be done as part of that \n
45 * transaction.\n
46 * \n
47 * Note: \n
48 * SERIALIZABLE isolation level is not supported. \n
50 class AbsSqlConnection
52 protected:
53 AbsSqlConnection *innerConn;
54 public:
55 void setInnerConnection(AbsSqlConnection *conn) { innerConn = conn; }
56 AbsSqlConnection* getInnerConnection() { return innerConn; }
57 virtual Connection& getConnObject() =0;
59 /** opens connection to the sql engine
60 * @param user username for authentication
61 * @param pass password for authentication
62 * @return DbRetVal
64 virtual DbRetVal connect (char *user, char * pass) =0;
66 /** closes connection to the sql engine and releases all the resources
67 * @return DbRetVal
69 virtual DbRetVal disconnect () = 0;
71 /** Commits active transaction. \n
72 * It makes all the changes made in the current transaction permanent and \n
73 * it also releases the locks held by the current transaction.\n
74 * After a transaction commits, application is required to start another \n
75 * transaction for further database operations.\n
76 * @return DbRetVal
78 virtual DbRetVal commit() = 0;
80 /** Aborts the active transaction.\n
81 * undo all the changes made in the current transaction and it also \n
82 * releases the locks held by the current transaction.\n
83 * After a transaction rollback, application is required to start another \n
84 * transaction for further database operations.\n
85 * @return DbRetVal
87 virtual DbRetVal rollback() = 0;
89 /** Starts a new transaction.\n
90 * The previous transaction should be either committed or rollback \n
91 * before beginTrans is called. \n
92 * Applications are required to start transaction before they attempt any \n
93 * database operation.\n
94 * @param isoLevel isolation level. Default is read committed.
95 * @return DbRetVal
97 virtual DbRetVal beginTrans (IsolationLevel isoLevel = READ_COMMITTED,
98 TransSyncMode mode = OSYNC) = 0;
99 virtual ~AbsSqlConnection(){}
103 #endif