test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
9  m_connection( 0 )
10 {
11  coral::Context& context = coral::Context::instance();
12  context.loadComponent( "CORAL/RelationalPlugins/oracle" );
13  coral::IHandle<coral::IRelationalDomain> domain = context.query<coral::IRelationalDomain>(
14 "CORAL/RelationalPlugins/oracle" );
15  if ( ! domain.isValid() )
16  throw std::runtime_error( "Could not load the OracleAccess plugin" );
17 }
18 
19 
21 {
22  if ( m_connection ) delete m_connection;
23 }
24 
25 
26 coral::ISession*
28  const std::string& userName,
29  const std::string& password )
30 {
31  coral::Context& ctx = coral::Context::instance();
32  ctx.loadComponent("CORAL/RelationalPlugins/oracle");
33  coral::IHandle<coral::IRelationalDomain> iHandle=ctx.query<coral::IRelationalDomain>("CORAL/RelationalPlugins/oracle");
34  if ( ! iHandle.isValid() ) {
35  throw std::runtime_error( "Could not load the OracleAccess plugin" );
36  }
37  std::pair<std::string, std::string> connectionAndSchema = iHandle->decodeUserConnectionString( connectionString );
38 
39  if ( ! m_connection )
40  m_connection = iHandle->newConnection( connectionAndSchema.first );
41 
42  if ( ! m_connection->isConnected() )
43  m_connection->connect();
44 
45  coral::ISession* session = m_connection->newSession( connectionAndSchema.second );
46 
47  if ( session ) {
48  session->startUserSession( userName, password );
49  }
50  //memory leaking
51  return session;
52 }
53 
54 
55 void
57 {
58  coral::MessageStream::setMsgVerbosity(level);
59 }
60 
61 
62 
static PFTauRenderPlugin instance
void setVerbosityLevel(coral::MsgLevel level)
Definition: RPCDBCom.cc:56
string connectionString
Definition: autoCondHLT.py:4
coral::ISession * connect(const std::string &connectionString, const std::string &userName, const std::string &password)
Definition: RPCDBCom.cc:27
coral::IConnection * m_connection
Definition: RPCDBCom.h:26
tuple level
Definition: testEve_cfg.py:34
virtual ~RPCDBCom()
Definition: RPCDBCom.cc:20
RPCDBCom()
Definition: RPCDBCom.cc:8