3#include "TBufferFile.h"
5 ISvcLocator* pSvcLocator )
6 : Algorithm ( name, pSvcLocator )
15 MsgStream log(
msgSvc(), name());
16 log << MSG::INFO <<
"Initialize()" << endreq;
19 return StatusCode::SUCCESS;
25 MsgStream log(
msgSvc(), name());
27 char *opt_host_name =
"bes3db2.ihep.ac.cn";
29 char *opt_user_name =
"maqm";
30 char *opt_password =
"maqm_offline";
31 unsigned int opt_port_num = 3306;
32 char *opt_socket_name = NULL;
33 char *opt_db_name =
"offlinedb";
34 unsigned int opt_flags = 0;
40conn = mysql_init(NULL);
42 mysql_real_connect(conn, opt_host_name, opt_user_name, opt_password,
43 opt_db_name, opt_port_num, opt_socket_name, opt_flags);
44 printf(
"connect the database ok\n");
49timenow = localtime(&now);
50printf(
"Local time is %s\n",asctime(timenow));
52 TFile *f =
new TFile(
"/ihepbatch/besd12/max/bBhabha_EsTime_run6018.root");
53 cout<<
"step11111111"<<endl;
55 TTree *Level0 = (TTree*)f-> Get(
"h2");
56 TBufferFile Level0_buf(TBuffer::kWrite);
57 Level0->Streamer(Level0_buf);
59 cout<<
"step22222222"<<endl;
61 TTree *Level1 = (TTree*)f-> Get(
"calibconst");
62 TBufferFile Level1_buf(TBuffer::kWrite);
63 Level1->Streamer(Level1_buf);
136char query[5024000],buf[1024*1000],buf1[1024*1000],*p,*p1;
137unsigned int from_len,from_len1;
143sprintf(query,
"INSERT INTO EsTimeCalConst(SerNo,RunFrom,RunTo,EsTimeH2,EsTimeH9) VALUES(%d,'100','1000','",
id);
145 printf(
"%s\n",query);
146 p= query + strlen(query);
147p += mysql_escape_string(p,Level0_buf.Buffer(),Level0_buf.BufferSize());
150cout<<
"strlen(query)22222222222="<<strlen(query)<<endl;
152 p= query + strlen(query);
153 p +=mysql_escape_string(p,Level1_buf.Buffer(),Level1_buf.BufferSize());
155 status = mysql_query(conn,query);
156 printf(
"%d\n",status);
163unsigned long *lengths;
172 sprintf(stmt1,
"select EsTimeH2,EsTimeH9,RunFrom,RunTo from TofCalConst where SerNo=%d",serno);
175 printf(
"%s\n",stmt1);
176 if(mysql_real_query(conn, stmt1, strlen(stmt1)) != 0)
177 printf(
"query error\n");
178 res_set = mysql_store_result (conn);
179 mysql_field_seek (res_set, 0);
181 row = mysql_fetch_row (res_set);
182 lengths = mysql_fetch_lengths(res_set);
185 cout<<
"lengths["<<i<<
"]="<<lengths[i]<<endl;
225 return StatusCode::SUCCESS;
229 MsgStream log(
msgSvc(), name());
231 <<
" CheckMYSQL FINALIZE!! "
234 return StatusCode::SUCCESS;
struct st_mysql_res MYSQL_RES
CheckMYSQL(const std::string &name, ISvcLocator *pSvcLocator)