adding test scripts
[csql.git] / include / AbsSqlConnection.h
blob5692dad98e4be0864e8b0005815f096c789caffe
1 /***************************************************************************
2 * *
3 * Copyright (C) Lakshya Solutions Ltd. All rights reserved. *
4 * *
5 ***************************************************************************/
6 #ifndef ABSSQLCONNECTION_H
7 #define ABSSQLCONNECTION_H
8 #include<os.h>
9 #include<ErrorType.h>
10 #include<Session.h>
11 #include<Util.h>
12 class Connection;
13 class CachedTable{
14 public:
15 char tableName[IDENTIFIER_LENGTH];
16 CachedTable() { tableName[0] = '\0'; }
19 enum TransSyncMode {
20 OSYNC=1,
21 ASYNC=2,
22 OASYNC=3
25 enum TableSyncMode {
26 TABLE_OSYNC=1,
27 TABLE_ASYNC=2
29 /**
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
37 * through SQL Engine.
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
40 * transaction.\n
41 * \n
42 * Note: \n
43 * SERIALIZABLE isolation level is not supported. \n
45 class AbsSqlConnection
47 protected:
48 AbsSqlConnection *innerConn;
49 public:
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
57 * @return DbRetVal
59 virtual DbRetVal connect (char *user, char * pass) =0;
61 /** closes connection to the sql engine and releases all the resources
62 * @return DbRetVal
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
71 * @return DbRetVal
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
80 * @return DbRetVal
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.
90 * @return DbRetVal
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();
104 #endif