1 /***************************************************************************
2 * Copyright (C) 2007 by www.databasecache.com *
3 * Contact: praba_tuty@databasecache.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 ***************************************************************************/
16 #include<SessionImpl.h>
21 Connection::~Connection()
27 DbRetVal
Connection::open(const char *username
, const char *password
)
29 if (session
== NULL
) session
= new SessionImpl();
30 DbRetVal rv
= logger
.startLogger(config
.getLogFile());
31 if (rv
!= OK
) { delete session
; session
= NULL
; return rv
; }
32 logFinest(logger
, "User logged in %s",username
);
33 return session
->open(username
, password
);
36 DbRetVal
Connection::close()
38 if (session
== NULL
) return ErrNoConnection
;
39 logFinest(logger
, "User logged out");
41 DbRetVal rv
= session
->close();
47 DatabaseManager
* Connection::getDatabaseManager()
49 if (session
== NULL
) return NULL
;
50 return session
->getDatabaseManager();
53 UserManager
* Connection::getUserManager()
55 if (session
== NULL
) return NULL
;
56 return session
->getUserManager();
59 DbRetVal
Connection::startTransaction(IsolationLevel level
)
61 if (session
== NULL
) return ErrNoConnection
;
62 return session
->startTransaction(level
);
66 DbRetVal
Connection::commit()
68 if (session
== NULL
) return ErrNoConnection
;
69 return session
->commit();
73 DbRetVal
Connection::rollback()
75 if (session
== NULL
) return ErrNoConnection
;
76 return session
->rollback();