BOSS 7.0.6
BESIII Offline Software System
Loading...
Searching...
No Matches
test_tof.cxx
Go to the documentation of this file.
1// $Header: /bes/bes/BossCvs/Calibration/rdbModel/src/test/test_build.cxx,v 1.1.1.1 2005/10/17 06:10:53 maqm Exp $
2// Test program for rdbModel primitive buiding blocks
3
4#include <iostream>
5#include <string>
6#include <cstdlib>
7#include <time.h>
8#include <stdio.h>
9#include <string.h>
10#include <mysql/mysql.h>
11#include <fstream>
12#define TEST_SQL
13
14int main(int argc, char** argv) {
15 char *opt_host_name = "bes3db1.ihep.ac.cn";
16 char *opt_user_name = "maqm";
17 unsigned int opt_port_num = 3306;
18 char *opt_socket_name = NULL;
19 char *opt_db_name = "offlinedb";
20 unsigned int opt_flags = 0;
21 MYSQL *conn;
22
23
24
25 conn = mysql_init(NULL);
26
27 mysql_real_connect(conn, opt_host_name, opt_user_name, opt_password,
28 opt_db_name, opt_port_num, opt_socket_name, opt_flags);
29 //printf("connect the database ok\n");
30 if(conn!=0){
31 std::cout<<"connect the database ok\n"<<std::endl;
32 }else{
33 std::cout<<"can't connect to the db:"<<std::endl;
34 return -1;
35 }
36
37unsigned long *lengths;
38
39 MYSQL_RES *res_set;
40 MYSQL_ROW row;
41
42 char stmt1[200];//="select context from mytesttable where id = %d,";
43 sprintf(stmt1,"select EtfTofPar from TofCalConst where serno = 2098");
44
45 printf("%s\n",stmt1);
46
47 int status = mysql_real_query(conn, stmt1, strlen(stmt1));
48 if(status)
49 {
50 std::cout << "Query is:" <<stmt1<< " failed: " << mysql_error(conn) << std::endl;
51 return -1;}
52 res_set = mysql_store_result (conn);
53 mysql_field_seek (res_set, 0);
54
55 //int lengths = 0;
56 row = mysql_fetch_row (res_set);
57 lengths = mysql_fetch_lengths(res_set);
58 std::cout<<"lengths[0]: " << lengths[0] <<std::endl;
59
60 mysql_free_result(res_set);
61
62 mysql_close(conn);
63
64
65
66 return 0;
67}
68
struct st_mysql_res MYSQL_RES
struct st_mysql MYSQL
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)
int main()
Definition: test_IFile.cxx:11