{ #include struct roundtrip { Int_t testid; Int_t microseconds; Int_t sourceid; Int_t destid; char datetime[20]; Float_t delay; Float_t jitter; Float_t loss; }; roundtrip vround; // create root file TFile *f1 = new TFile("/testesROOT/pipesbr_roundtrip.root", "RECREATE"); // create tree TTree *tree_round = new TTree("pipesbr_roundtrip", "Dados do PipesBr Unifacs RoundTrip"); //create branch tree_round->Branch("RoundTrip", &vround, "testid/I:microseconds:sourceid:destid:datetime/C:delay/F:jitter:loss"); //connect database TSQLServer *db = TSQLServer::Connect("mysql://200.241.22.1:3306/pipes","user", "pass"); //select from database TSQLResult *res_round = db->Query("select * from RoundTrip"); int nrows_round = res_round->GetRowCount(); int nfields_round = res_round->GetFieldCount(); printf("nfields:%d \n",nfields_round); printf("nrows:%d \n",nrows_round); //insert in the tree for (int i=0; i < nrows_round; i++) { TSQLRow *row_round = res_round->Next(); for (int j = 0; j < nfields_round; j++) { switch(j){ case 0: vround.testid = atoi(row_round->GetField(j)); break; case 1: strcpy(vround.datetime,row_round->GetField(j)); break; case 2: vround.microseconds = atoi(row_round->GetField(j)); break; case 3: vround.sourceid = atoi(row_round->GetField(j)); break; case 4: vround.destid = atoi(row_round->GetField(j)); break; case 5: if(row_round->GetField(j) == '\0') vround.delay = 0; else{ vround.delay = atof(row_round->GetField(j)); printf("%f \n",vround.delay); } break; case 6: if(row_round->GetField(j) == '\0') vround.jitter = 0; else{ vround.jitter = atof(row_round->GetField(j)); } break; case 7: if(row_round->GetField(j) == '\0') vround.loss = 0; else{ vround.loss = atof(row_round->GetField(j)); } break; default: printf("No other j \n"); } //end switch }//end for j tree_round->Fill(); delete row_round; }//end for i printf("done insertion \n"); delete res_round; delete db; f1->Write(); tree_round->Scan(); }