posts - 97,  comments - 5,  trackbacks - 0
          #include "lrd.h"
           Action()
           {
          double trans_time;  //定義一個double型變量用來保存事務執行時間

           static LRD_INIT_INFO InitInfo = {LRD_INIT_INFO_EYECAT};
           static LRD_DEFAULT_DB_VERSION DBTypeVersion[] =
           {
             {LRD_DBTYPE_ODBC, LRD_DBVERSION_ODBC_30},
             {LRD_DBTYPE_NONE, LRD_DBVERSION_NONE}
           };
           static LRD_CONTEXT FAR * Ctx1;
           static LRD_CONNECTION FAR * Con1;
           static LRD_CURSOR FAR *     Csr1;
           //上面的定義的代碼如果錄制腳本,在vdf.h中就有定義,同時還有一些其他文件
          //如果手寫腳本,則需要手工添加,主要是定義各種變量
          //查詢行數
          unsigned long count=0;


           //初始
          lrd_init(&InitInfo, DBTypeVersion);
           //打開上下文
          lrd_open_context(&Ctx1, LRD_DBTYPE_ODBC, 0, 0, 0);
           //申請連接的內存
          lrd_alloc_connection(&Con1, LRD_DBTYPE_ODBC, Ctx1, 0 /*Unused*/, 0);
           //打開連接,注意DRIVER就是上面安裝的
          lrd_open_connection(&Con1, LRD_DBTYPE_ODBC, "", "","", "DRIVER=MySQL ODBC 3.51 Driver;UID=bydapp;PWD=Rootuser;SERVER=10.66.64.20;DATABASE=bydfans; PORT=3306", Ctx1, 1, 0);
           //打開游標
          lrd_open_cursor(&Csr1, Con1, 0);


          lr_rendezvous("selectmysql");
          lr_start_transaction("selectmysql");

           //Sql語句,注意1代表的意思是,立馬執行
          lrd_stmt(Csr1, "select n_user_id, c_user_accounts, c_user_password, c_user_name, c_user_phone, c_user_mail, c_user_status, c_user_reg, c_user_second, c_phone_token, c_account_weight_value, c_user_no "
                         "from t_user_account "
                         "WHERE ( c_user_accounts = 'wuguo' and c_user_password = 'e10adc3949ba59abbe56e057f20f883e' and c_user_status = '1' )",
                    -1, 1, 0 /*None*/, 0);


          lrd_stmt(Csr1, "select * from t_user_account", -1, 1, 0 /*None*/, 0);

          trans_time=lr_get_transaction_duration( "selectmysql" ); //獲得該SQL的執行時間

          lr_output_message("start_select事務耗時 %f 秒", trans_time); //輸出該時間
          lr_end_transaction("selectmysql", LR_AUTO);


           //統計行數到count變量中
          lrd_row_count(Csr1, &count, 0);
           //打印消息
          lr_message("count= %d",count);
           //先關閉游標
          lrd_close_cursor(&Csr1, 0);
           //再關閉連接
          lrd_close_connection(&Con1, 0, 0);
           //釋放連接,和alloc相呼應,否則有內存泄露
          lrd_free_connection(&Con1, 0 /*Unused*/, 0);
           //再關閉上下文
          lrd_close_context(&Ctx1, 0, 0);
           //完畢,返回0

           return 0;
           }
           

           

          天貓 軟件自動化測試開發

          posted on 2014-03-23 18:02 zouhui 閱讀(565) 評論(0)  編輯  收藏 所屬分類: 2.軟件測試 性能自動化
          <2014年3月>
          2324252627281
          2345678
          9101112131415
          16171819202122
          23242526272829
          303112345

          常用鏈接

          留言簿(2)

          隨筆分類(94)

          隨筆檔案(94)

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 荣成市| 新河县| 金坛市| 卢龙县| 彩票| 吉隆县| 宣威市| 石家庄市| 宝山区| 仁寿县| 兴海县| 泌阳县| 大关县| 长泰县| 绵阳市| 尼勒克县| 阿拉善左旗| 抚松县| 那坡县| 桃江县| 万全县| 密山市| 禄劝| 玉田县| 泸溪县| 桂阳县| 宝山区| 台南县| 涪陵区| 通辽市| 大关县| 浮梁县| 刚察县| 于都县| 铜川市| 榆社县| 兴安县| 陇西县| 闵行区| 兰溪市| 正阳县|