CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ConnectionManager.cc
Go to the documentation of this file.
1 
2 #include <cstring>
3 #include <cstdio>
4 
7 #include <cctype>
8 
10 }
11 
12 static const std::string keyFile("/nfshome0/hcalsw/.ReadOMDSKey");
13 
14 static void clean(char* s) {
15  for (int x=strlen(s)-1; x>=0; x--) {
16  if (isspace(s[x])) s[x]=0;
17  }
18 }
19 
21  if (env!=0) return true;
22  std::string username,password,database;
23 
24  char s[100];
25  FILE* f=fopen(keyFile.c_str(),"r");
26  s[0]=0; fgets(s,100,f); clean(s); username=s;
27  s[0]=0; fgets(s,100,f); clean(s); password=s;
28  s[0]=0; fgets(s,100,f); clean(s); database=s;
29  fclose(f);
30 
31  // printf("'%s' '%s' '%s'\n",username.c_str(),password.c_str(),database.c_str());
32  try {
33  env = oracle::occi::Environment::createEnvironment (oracle::occi::Environment::DEFAULT);
34  conn = env->createConnection (username, password, database);
35  } catch (...) {
36  return false;
37  }
38  return true;
39 }
40 oracle::occi::Statement* ConnectionManager::getStatement(const std::string& query) {
41  if (env==0) return 0;
42  return conn->createStatement(query);
43 }
45  if (env==0) return;
46  env->terminateConnection(conn);
47  oracle::occi::Environment::terminateEnvironment(env);
48  env=0; conn=0;
49 }
oracle::occi::Connection * conn
oracle::occi::Statement * getStatement(const std::string &query)
double f[11][100]
std::vector< T * > clean
Definition: MVATrainer.cc:156
static const std::string keyFile("/nfshome0/hcalsw/.ReadOMDSKey")
tuple query
Definition: o2o.py:269
Definition: DDAxes.h:10
tuple conn
Definition: results_mgr.py:53
oracle::occi::Environment * env