CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
ConnectionManager Class Reference

#include <ConnectionManager.h>

Public Member Functions

bool connect ()
 
 ConnectionManager ()
 
void disconnect ()
 
oracle::occi::Statement * getStatement (const std::string &query)
 

Private Attributes

oracle::occi::Connection * conn
 
oracle::occi::Environment * env
 

Detailed Description

Definition at line 14 of file ConnectionManager.h.

Constructor & Destructor Documentation

ConnectionManager::ConnectionManager ( )

Definition at line 9 of file ConnectionManager.cc.

References keyFile(), and AlCaHLTBitMon_QueryRunRegistry::string.

9 : env(nullptr), conn(nullptr) {}
oracle::occi::Connection * conn
oracle::occi::Environment * env

Member Function Documentation

bool ConnectionManager::connect ( )

Definition at line 20 of file ConnectionManager.cc.

References clean(), conn, SiStripPI::DEFAULT, env, f, keyFile(), EcalCondDBWriter_cfi::password, alignCSCRings::s, AlCaHLTBitMon_QueryRunRegistry::string, and personalPlayback::username.

Referenced by Vispa.Gui.ZoomableScrollArea.ZoomableScrollArea::__init__(), Vispa.Views.PropertyView.BooleanProperty::__init__(), Vispa.Gui.FindDialog.FindDialog::_addScript(), Vispa.Gui.FindDialog.FindDialog::_addStringProperty(), Vispa.Main.Application.Application::_connectSignals(), Vispa.Plugins.ConfigEditor.CodeTableView.CodeTableView::_createItem(), Vispa.Gui.BoxContentDialog.BoxContentDialog::addButton(), Vispa.Gui.ToolBoxContainer.ToolBoxContainer::addWidget(), Vispa.Views.PropertyView.PropertyView::append(), Vispa.Views.PropertyView.PropertyView::appendAddRow(), Vispa.Main.Application.Application::createAction(), Vispa.Views.PropertyView.TextEditWithButtonProperty::createButton(), Vispa.Views.LineDecayView.LineDecayView::createLineDecayContainer(), Vispa.Views.PropertyView.TextEditWithButtonProperty::createLineEdit(), Vispa.Views.LineDecayView.LineDecayContainer::createObject(), Vispa.Views.PropertyView.TextEditWithButtonProperty::createTextEdit(), Vispa.Plugins.Browser.BrowserTabController.BrowserTabController::filterDialog(), Vispa.Plugins.Browser.BrowserTabController.BrowserTabController::find(), HcalAssistant::getListOfChannelsFromDb(), Vispa.Gui.PortWidget.PortWidget::mouseMoveEvent(), Vispa.Views.PropertyView.BooleanProperty::setChecked(), Vispa.Main.SplitterTab.SplitterTab::setController(), Vispa.Plugins.Browser.BrowserTab.BrowserTab::setController(), Vispa.Views.PropertyView.BooleanProperty::setReadOnly(), Vispa.Views.PropertyView.DropDownProperty::setReadOnly(), Vispa.Views.PropertyView.TextEditWithButtonProperty::setReadOnly(), Vispa.Plugins.Browser.BrowserTabController.BrowserTabController::setTab(), Vispa.Views.PropertyView.IntegerProperty::setValue(), Vispa.Plugins.Browser.BrowserTabController.BrowserTabController::switchCenterView(), o2o_db_cfgmap.DbManagerDAQ::update_hashmap(), Vispa.Plugins.EdmBrowser.EdmBrowserTabController.EdmBrowserTabController::updateViewMenu(), and Vispa.Plugins.ConfigEditor.ConfigEditorTabController.ConfigEditorTabController::updateViewMenu().

20  {
21  if (env != nullptr)
22  return true;
23  std::string username, password, database;
24 
25  char s[100];
26  FILE* f = fopen(keyFile.c_str(), "r");
27  s[0] = 0;
28  fgets(s, 100, f);
29  clean(s);
30  username = s;
31  s[0] = 0;
32  fgets(s, 100, f);
33  clean(s);
34  password = s;
35  s[0] = 0;
36  fgets(s, 100, f);
37  clean(s);
38  database = s;
39  fclose(f);
40 
41  // printf("'%s' '%s' '%s'\n",username.c_str(),password.c_str(),database.c_str());
42  try {
43  env = oracle::occi::Environment::createEnvironment(oracle::occi::Environment::DEFAULT);
44  conn = env->createConnection(username, password, database);
45  } catch (...) {
46  return false;
47  }
48  return true;
49 }
oracle::occi::Connection * conn
static void clean(char *s)
double f[11][100]
static const std::string keyFile("/nfshome0/hcalsw/.ReadOMDSKey")
oracle::occi::Environment * env
void ConnectionManager::disconnect ( )
oracle::occi::Statement * ConnectionManager::getStatement ( const std::string &  query)

Definition at line 50 of file ConnectionManager.cc.

References conn, and env.

Referenced by HcalAssistant::getListOfChannelsFromDb().

50  {
51  if (env == nullptr)
52  return nullptr;
53  return conn->createStatement(query);
54 }
oracle::occi::Connection * conn
Definition: query.py:1
oracle::occi::Environment * env

Member Data Documentation

oracle::occi::Connection* ConnectionManager::conn
private

Definition at line 23 of file ConnectionManager.h.

Referenced by connect(), disconnect(), and getStatement().

oracle::occi::Environment* ConnectionManager::env
private

Definition at line 22 of file ConnectionManager.h.

Referenced by connect(), disconnect(), and getStatement().