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 閱讀(566) 評論(0)  編輯  收藏 所屬分類: 2.軟件測試 性能自動化
          <2014年3月>
          2324252627281
          2345678
          9101112131415
          16171819202122
          23242526272829
          303112345

          常用鏈接

          留言簿(2)

          隨筆分類(94)

          隨筆檔案(94)

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 建宁县| 从化市| 渑池县| 杭锦后旗| 兴安县| 永吉县| 凤翔县| 临武县| 汉阴县| 商都县| 临澧县| 陇川县| 曲麻莱县| 于都县| 婺源县| 英山县| 江川县| 都匀市| 洛南县| 澄迈县| 渑池县| 宁晋县| 尉犁县| 奇台县| 滨州市| 石景山区| 包头市| 清水县| 夏邑县| 建宁县| 武功县| 溧水县| 宁明县| 女性| 莱阳市| 阿坝县| 永康市| 崇阳县| 富顺县| 安龙县| 礼泉县|