00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef SQLCONNECTION_H
00021 #define SQLCONNECTION_H
00022 #include<CSql.h>
00023 #include<AbsSqlConnection.h>
00024 #include<SqlFactory.h>
00025
00026 class SqlConnection : public AbsSqlConnection
00027 {
00028 Connection conn;
00029 bool isConnOpen;
00030 public:
00031 SqlConnection(){innerConn = NULL; isConnOpen = false; }
00032
00038 DbRetVal connect (char *user, char * pass) {
00039 DbRetVal ret = conn.open(user, pass);
00040 if (ret == OK) isConnOpen = true;
00041 return ret;
00042 }
00043
00047 DbRetVal disconnect () {
00048 DbRetVal ret = conn.close();
00049 if (ret == OK) isConnOpen = false;
00050 return ret;
00051 }
00052
00060 DbRetVal commit() { return conn.commit(); }
00061
00069 DbRetVal rollback() { return conn.rollback(); }
00070
00079 DbRetVal beginTrans (IsolationLevel isoLevel = READ_COMMITTED,
00080 TransSyncMode mode = OSYNC)
00081 { return conn.startTransaction(isoLevel); }
00082
00083 Connection& getConnObject(){ return conn; }
00084 bool isConnectionOpen() { if (isConnOpen) return true; return false; };
00085
00086 friend class SqlFactory;
00087 };
00088
00089 #endif