10#include <mysql/mysql.h>
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;
25 conn = mysql_init(NULL);
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);
31 std::cout<<
"connect the database ok\n"<<std::endl;
33 std::cout<<
"can't connect to the db:"<<std::endl;
37unsigned long *lengths;
43 sprintf(stmt1,
"select EtfTofPar from TofCalConst where serno = 2098");
47 int status = mysql_real_query(conn, stmt1, strlen(stmt1));
50 std::cout <<
"Query is:" <<stmt1<<
" failed: " << mysql_error(conn) << std::endl;
52 res_set = mysql_store_result (conn);
53 mysql_field_seek (res_set, 0);
56 row = mysql_fetch_row (res_set);
57 lengths = mysql_fetch_lengths(res_set);
58 std::cout<<
"lengths[0]: " << lengths[0] <<std::endl;
60 mysql_free_result(res_set);
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)