CaloOnlineTools
HcalOnlineDb
src
ConnectionManager.cc
Go to the documentation of this file.
1
2
#include <cstring>
3
#include <cstdio>
4
5
#include "
OnlineDB/Oracle/interface/Oracle.h
"
6
#include "
CaloOnlineTools/HcalOnlineDb/interface/ConnectionManager.h
"
7
#include <cctype>
8
9
ConnectionManager::ConnectionManager
() :
env
(nullptr),
conn
(nullptr) {}
10
11
static
const
std::string
keyFile
(
"/nfshome0/hcalsw/.ReadOMDSKey"
);
12
13
static
void
clean
(
char
*
s
) {
14
for
(
int
x
= strlen(
s
) - 1;
x
>= 0;
x
--) {
15
if
(isspace(
s
[
x
]))
16
s
[
x
] = 0;
17
}
18
}
19
20
bool
ConnectionManager::connect
() {
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
}
50
oracle::occi::Statement*
ConnectionManager::getStatement
(
const
std::string
&
query
) {
51
if
(
env
==
nullptr
)
52
return
nullptr
;
53
return
conn
->createStatement(
query
);
54
}
55
void
ConnectionManager::disconnect
() {
56
if
(
env
==
nullptr
)
57
return
;
58
env
->terminateConnection(
conn
);
59
oracle::occi::Environment::terminateEnvironment(
env
);
60
env
=
nullptr
;
61
conn
=
nullptr
;
62
}
f
double f[11][100]
Definition:
MuScleFitUtils.cc:78
SiStripPI::DEFAULT
Definition:
SiStripPayloadInspectorHelper.h:786
ConnectionManager::disconnect
void disconnect()
Definition:
ConnectionManager.cc:55
SiStripCommissioningClient_cfg.conn
conn
Definition:
SiStripCommissioningClient_cfg.py:5
alignCSCRings.s
s
Definition:
alignCSCRings.py:92
ConnectionManager::env
oracle::occi::Environment * env
Definition:
ConnectionManager.h:22
EcalCondDBWriter_cfi.password
password
Definition:
EcalCondDBWriter_cfi.py:62
query
Definition:
query.py:1
keyFile
static const std::string keyFile("/nfshome0/hcalsw/.ReadOMDSKey")
ConnectionManager::getStatement
oracle::occi::Statement * getStatement(const std::string &query)
Definition:
ConnectionManager.cc:50
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition:
AlCaHLTBitMon_QueryRunRegistry.py:256
web.browse_db.env
env
Definition:
browse_db.py:18
ConnectionManager::connect
bool connect()
Definition:
ConnectionManager.cc:20
ConnectionManager::ConnectionManager
ConnectionManager()
Definition:
ConnectionManager.cc:9
personalPlayback.username
username
Definition:
personalPlayback.py:449
clean
static void clean(char *s)
Definition:
ConnectionManager.cc:13
genVertex_cff.x
x
Definition:
genVertex_cff.py:12
Oracle.h
ConnectionManager.h
ConnectionManager::conn
oracle::occi::Connection * conn
Definition:
ConnectionManager.h:23
Generated for CMSSW Reference Manual by
1.8.16