FEDRA emulsion software from the OPERA Collaboration
TOracleServer.cxx File Reference
#include "TOracleServer.h"
#include "TOracleResult.h"
#include "TUrl.h"
#include "TTree.h"
#include "TString.h"
#include "EdbLog.h"
Include dependency graph for TOracleServer.cxx:

Functions

 ClassImp (TOracleServer) TOracleServer
 

Function Documentation

◆ ClassImp()

ClassImp ( TOracleServer  )
23 {
24  // Open a connection to a Oracle DB server. The db arguments should be
25  // of the form "oracle://connection_identifier][/<database>]", e.g.:
26  // "oracle://cmscald.fnal.gov/test". The uid is the username and pw
27  // the password that should be used for the connection.
28 
29  fEnv = 0;
30  fConn = 0;
31  fStmt = 0;
32 
33  TUrl url(db);
34 
35  if (!url.IsValid()) {
36  Error("TOracleServer", "malformed db argument %s", db);
37  MakeZombie();
38  return;
39  }
40 
41  if (strncmp(url.GetProtocol(), "oracle", 6)) {
42  Error("TOracleServer", "protocol in db argument should be oracle it is %s",
43  url.GetProtocol());
44  MakeZombie();
45  return;
46  }
47 
48  const char *conn_str = url.GetFile();
49  if (conn_str[0]=='/') conn_str++; // in new root versions url.GetFile() return name without '/'
50 
51  try {
52  fEnv = Environment::createEnvironment();
53  Log(2,"TOracleServer","connect to database %s..\n",conn_str);
54  fConn = fEnv->createConnection(uid, pw, conn_str);
55 
56  fType = "Oracle";
57  fHost = url.GetHost();
58  fDB = conn_str;
59  fPort = url.GetPort();
60  fPort = (fPort) ? fPort : 1521;
61  } catch (SQLException &oraex) {
62  Error("TOracleServer", "connection to Oracle database %s failed (error: %s)",conn_str, (oraex.getMessage()).c_str());
63  MakeZombie();
64  }
65 }
bool Log(int level, const char *location, const char *fmt,...)
Definition: EdbLog.cxx:75
TOracleServerE * db
Definition: test_oracle.C:8