HCE project C++ developers source code library  1.1.1
HCE project developer library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
DBSession.cpp
Go to the documentation of this file.
1 #include "DBSession.hpp"
2 
3 namespace HCE {
4  namespace database {
5  DBSession::DBSession (const std::string& KEY,const std::string& dbConnString) {
6  //Poco::Data::Session can throws an exception which passing up on hierarchy
7  this->_pSession = new Poco::Data::Session(Poco::Data::SessionFactory::instance().create(KEY, dbConnString.c_str()));
8  }
9 
10  DBSession::~DBSession () throw () {
11  this->close();
12  }
13 
14  void DBSession::close () throw () {
15  Poco::Mutex::ScopedLock lock(this->mutex);
16  if (!this->_pSession.isNull() && this->_pSession->isConnected() == true) {
17  this->_pSession->close();
18  }
19  else {
20  //...
21  }
22  }
23 
24  bool DBSession::isConnected () throw (){
25  Poco::Mutex::ScopedLock lock(this->mutex);
26  return this->_pSession->isConnected();
27  }
28  }
29 }