BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
test_db.C
Go to the documentation of this file.
1void test_db()
2{
3 TStopwatch timer;
4 timer.Start();
5 gDebug = 0;
6
8 if (connDb == nullptr)
9 return;
10
11 TSQLServer* uni_db = connDb->GetSQLServer();
12
13 cout << "Host: " << uni_db->GetHost() << ". DB: " << uni_db->GetDB() << ". Type: " << uni_db->GetDBMS() << "."
14 << endl;
15
16 int iParameterID = 1;
17 TSQLStatement* stmt = uni_db->Statement(TString::Format("select parameter_name "
18 "from parameter_ "
19 "where parameter_id = %d",
20 iParameterID));
21
22 stmt->Process();
23 // store result of statement in buffer
24 stmt->StoreResult();
25
26 // extract rows one after another
27 if (!stmt->NextResultRow()) {
28 cout << "ERROR: parameter with number 1 wasn't found!" << endl;
29 delete stmt;
30 return;
31 }
32
33 TString parameter_name = stmt->GetString(0);
34 delete stmt;
35 delete connDb;
36
37 timer.Stop();
38 Double_t rtime = timer.RealTime(), ctime = timer.CpuTime();
39 printf("RealTime=%f seconds, CpuTime=%f seconds\n", rtime, ctime);
40
41 cout << "Test was successfull" << endl;
42}
Int_t gDebug
double Double_t
const char * GetDB() const
const char * GetHost() const
const char * GetDBMS() const
virtual TSQLStatement * Statement(const char *, Int_t=100)
virtual const char * GetString(Int_t)
virtual Bool_t NextResultRow()=0
virtual Bool_t Process()=0
virtual Bool_t StoreResult()=0
Double_t RealTime()
void Start(Bool_t reset=kTRUE)
Double_t CpuTime()
void Stop()
static TString Format(const char *fmt,...)
static UniConnection * Open()
TSQLServer * GetSQLServer()
void test_db()
Definition test_db.C:1