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 SQLCONNECTION_H
21 #define SQLCONNECTION_H
25 * @class SqlConnection
27 * @brief Represents a database connection to sql engine.
28 * All database operations shall be done within the context of the connection. <br>
29 * Application should first create object of this class for accessing the database.<br/>
30 * Each connection has only one active transaction at any given point of time, all <br/>
31 * operations which happen using this connection object will be done as part of that <br/>
34 * Functionality: <br/>
35 * 1.Connection Management (connect and disconnect) <br/>
36 * 2.Transaction Management (start, commit, abort) <br/>
39 * SERIALIZABLE isolation level is not supported.
40 * @author Prabakaran Thirumalai
47 /** opens connection to the sql engine
48 * @param user username for authentication
49 * @param pass password for authentication
52 DbRetVal
connect (char *user
, char * pass
)
53 { return conn
.open(user
, pass
); }
55 /** closes connection to the database and releases all the resources
58 DbRetVal
disconnect () { return conn
.close(); }
60 /** Commits active transaction.
61 * It makes all the changes made in the current transaction permanent and <br/>
62 * it also releases the locks held by the current transaction.<br/>
63 * After a transaction commits, application is required to start another <br/>
64 * transaction for further database operations.
67 DbRetVal
commit() { return conn
.commit(); }
69 /** Aborts the active transaction.
70 * undo all the changes made in the current transaction and it also <br/>
71 * releases the locks held by the current transaction.<br/>
72 * After a transaction rollback, application is required to start another <br/>
73 * transaction for further database operations.
76 DbRetVal
rollback() { return conn
.rollback(); }
78 /** Starts a transaction.
79 * The previous transaction should be either committed or rollback <br/>
80 * before beginTrans is called. <br/>
81 * Applications are required to start transaction before they attempt any <br>
83 * @param isoLevel isolation level. Default is read committed.
86 DbRetVal
beginTrans (IsolationLevel isoLevel
= READ_COMMITTED
)
87 { return conn
.startTransaction(isoLevel
); }
89 Connection
& getConnObject(){ return conn
; }