Gather data from DB. More...
#include <DBInterface.h>
Public Member Functions | |
DBInterface (const std::string &fDb, bool fVerbose=false) | |
~DBInterface () | |
Protected Member Functions | |
template<class T > | |
bool | getObjectGeneric (T *fObject, const std::string &fTag) |
Protected Attributes | |
oracle::occi::Connection * | mConnect |
oracle::occi::Environment * | mEnvironment |
oracle::occi::Statement * | mStatement |
bool | mVerbose |
Gather data from DB.
Definition at line 27 of file DBInterface.h.
DBInterface::DBInterface | ( | const std::string & | fDb, |
bool | fVerbose = false |
||
) |
Definition at line 16 of file DBInterface.cc.
References benchmark_cfg::cerr, query::host, mConnect, mEnvironment, mStatement, and hcal_dqm_sourceclient-file_cfg::user.
: mConnect (0), mVerbose (fVerbose) { mEnvironment = oracle::occi::Environment::createEnvironment (oracle::occi::Environment::OBJECT); // decode connect string size_t ipass = fDb.find ('/'); size_t ihost = fDb.find ('@'); if (ipass == std::string::npos || ihost == std::string::npos) { std::cerr << "DBInterface::DBInterface-> Error in connection std::string format: " << fDb << " Expect user/password@db" << std::endl; } else { std::string user (fDb, 0, ipass); std::string pass (fDb, ipass+1, ihost-ipass-1); std::string host (fDb, ihost+1); // std::cout << "DBInterface::DBInterface-> Connecting " << user << '/' << pass << '@' << host << std::endl; try { mConnect = mEnvironment->createConnection(user, pass, host); mStatement = mConnect->createStatement (); } catch (oracle::occi::SQLException& sqlExcp) { std::cerr << "DBInterface::DBInterface exception-> " << sqlExcp.getErrorCode () << ": " << sqlExcp.what () << std::endl; } } }
DBInterface::~DBInterface | ( | ) |
Definition at line 44 of file DBInterface.cc.
References mConnect, mEnvironment, and mStatement.
{ delete mStatement; mEnvironment->terminateConnection (mConnect); oracle::occi::Environment::terminateEnvironment (mEnvironment); }
bool DBInterface::getObjectGeneric | ( | T * | fObject, |
const std::string & | fTag | ||
) | [protected] |
oracle::occi::Connection* DBInterface::mConnect [protected] |
Definition at line 35 of file DBInterface.h.
Referenced by DBInterface(), and ~DBInterface().
oracle::occi::Environment* DBInterface::mEnvironment [protected] |
Definition at line 34 of file DBInterface.h.
Referenced by DBInterface(), and ~DBInterface().
oracle::occi::Statement* DBInterface::mStatement [protected] |
Definition at line 36 of file DBInterface.h.
Referenced by DBInterface(), and ~DBInterface().
bool DBInterface::mVerbose [protected] |
Definition at line 38 of file DBInterface.h.