19 {
20 char *opt_host_name = "202.122.37.69";
21 char *opt_user_name = "maqm";
22 unsigned int opt_port_num = 3306;
23 char *opt_socket_name = NULL;
24 char *opt_db_name = "offlinedb";
25
26 unsigned int opt_flags = 0;
28
29
30
31conn = mysql_init(NULL);
32
33 mysql_real_connect(conn, opt_host_name, opt_user_name, opt_password,
34 opt_db_name, opt_port_num, opt_socket_name, opt_flags);
35 printf("connect the database ok\n");
36
37unsigned long *lengths;
38
40 MYSQL_ROW row;
41
42
43
44
45
46 char stmt1[200];
47 sprintf(stmt1,
"select TH1F_col from DedxSim where serno = 38");
48
49 printf("%s\n",stmt1);
50 if(mysql_real_query(conn, stmt1, strlen(stmt1)) != 0)
51 printf("query error\n");
52 res_set = mysql_store_result (conn);
53 mysql_field_seek (res_set, 0);
54
55 row = mysql_fetch_row (res_set);
56 lengths = mysql_fetch_lengths(res_set);
57 for(int i=0;i<5;i++){
58 std::cout<<"lengths["<<i<<"]="<<lengths[i]<<std::endl;
59 }
60
61
62
63
64
65
66 TBufferFile rootBuffer2(TBufferFile::kRead,lengths[0], row[0], kFALSE);
67 TTree tree;
68
69 tree.Streamer(rootBuffer2);
70
71
72 tree.Print();
73
74
75
76
77
78
79
80
81
82
83 int runno;
84 double rungain;
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104 return 0;
105}
struct st_mysql_res MYSQL_RES
sprintf(cut,"kal_costheta0_em>-0.93&&kal_costheta0_em<0.93&&kal_pxy0_em>=0.05+%d*0.1&&kal_pxy0_em<0.15+%d*0.1&&NGch>=2", j, j)