Enterprise to opensource. 40 files including Makefil.am and .in from storage, sqllog...
[csql.git] / include / AbsSqlConnection.h
blobf767126b6f460cf97db18ff5fc9cc30cf2b93ab4
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 class CachedTable{
25 public:
26 char tableName[IDENTIFIER_LENGTH];
29 enum TransSyncMode {
30 OSYNC=1,
31 ASYNC=2,
32 OASYNC=3
35 enum TableSyncMode {
36 TABLE_OSYNC=1,
37 TABLE_ASYNC=2
39 /**
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
47 * through SQL Engine.
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
50 * transaction.\n
51 * \n
52 * Note: \n
53 * SERIALIZABLE isolation level is not supported. \n
55 class AbsSqlConnection
57 protected:
58 AbsSqlConnection *innerConn;
59 public:
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
67 * @return DbRetVal
69 virtual DbRetVal connect (char *user, char * pass) =0;
71 /** closes connection to the sql engine and releases all the resources
72 * @return DbRetVal
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
81 * @return DbRetVal
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
90 * @return DbRetVal
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.
100 * @return DbRetVal
102 virtual DbRetVal beginTrans (IsolationLevel isoLevel = READ_COMMITTED,
103 TransSyncMode mode = OSYNC) = 0;
104 virtual ~AbsSqlConnection(){}
108 #endif