CMS 3D CMS Logo

RPCDBCom.cc
Go to the documentation of this file.
2 #include "RelationalAccess/IRelationalDomain.h"
3 #include "RelationalAccess/IConnection.h"
4 #include "RelationalAccess/ISession.h"
5 #include "RelationalAccess/RelationalServiceException.h"
6 #include "CoralKernel/Context.h"
7 
8 RPCDBCom::RPCDBCom() : m_connection(nullptr) {
9  coral::Context& context = coral::Context::instance();
10  context.loadComponent("CORAL/RelationalPlugins/oracle");
11  coral::IHandle<coral::IRelationalDomain> domain =
12  context.query<coral::IRelationalDomain>("CORAL/RelationalPlugins/oracle");
13  if (!domain.isValid())
14  throw std::runtime_error("Could not load the OracleAccess plugin");
15 }
16 
18  if (m_connection)
19  delete m_connection;
20 }
21 
23  const std::string& userName,
24  const std::string& password) {
25  coral::Context& ctx = coral::Context::instance();
26  ctx.loadComponent("CORAL/RelationalPlugins/oracle");
27  coral::IHandle<coral::IRelationalDomain> iHandle =
28  ctx.query<coral::IRelationalDomain>("CORAL/RelationalPlugins/oracle");
29  if (!iHandle.isValid()) {
30  throw std::runtime_error("Could not load the OracleAccess plugin");
31  }
32  std::pair<std::string, std::string> connectionAndSchema = iHandle->decodeUserConnectionString(connectionString);
33 
34  if (!m_connection)
35  m_connection = iHandle->newConnection(connectionAndSchema.first);
36 
37  if (!m_connection->isConnected())
38  m_connection->connect();
39 
40  coral::ISession* session = m_connection->newSession(connectionAndSchema.second);
41 
42  if (session) {
43  session->startUserSession(userName, password);
44  }
45  //memory leaking
46  return session;
47 }
48 
49 void RPCDBCom::setVerbosityLevel(coral::MsgLevel level) { coral::MessageStream::setMsgVerbosity(level); }
personalPlayback.level
level
Definition: personalPlayback.py:22
RPCDBCom::m_connection
coral::IConnection * m_connection
Definition: RPCDBCom.h:25
RPCDBCom::connect
coral::ISession * connect(const std::string &connectionString, const std::string &userName, const std::string &password)
Definition: RPCDBCom.cc:22
EcalCondDBWriter_cfi.userName
userName
Definition: EcalCondDBWriter_cfi.py:61
EcalCondDBWriter_cfi.password
password
Definition: EcalCondDBWriter_cfi.py:62
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
RPCDBCom.h
RPCDBCom::setVerbosityLevel
void setVerbosityLevel(coral::MsgLevel level)
Definition: RPCDBCom.cc:49
instance
static PFTauRenderPlugin instance
Definition: PFTauRenderPlugin.cc:70
RPCDBCom::~RPCDBCom
virtual ~RPCDBCom()
Definition: RPCDBCom.cc:17
l1RCTOmdsFedVectorProducer_cfi.connectionString
connectionString
Definition: l1RCTOmdsFedVectorProducer_cfi.py:4
RPCDBCom::RPCDBCom
RPCDBCom()
Definition: RPCDBCom.cc:8