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); }
static PFTauRenderPlugin instance
void setVerbosityLevel(coral::MsgLevel level)
Definition: RPCDBCom.cc:49
coral::ISession * connect(const std::string &connectionString, const std::string &userName, const std::string &password)
Definition: RPCDBCom.cc:22
coral::IConnection * m_connection
Definition: RPCDBCom.h:25
virtual ~RPCDBCom()
Definition: RPCDBCom.cc:17
RPCDBCom()
Definition: RPCDBCom.cc:8