#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;

}

最新文章

  1. 抽象类和抽象方法(关键字abstract)
  2. win 7安装 linux
  3. 设置搜狗输入法在任何时候按左右两侧的shift激活
  4. Ext学习-高级组件介绍
  5. ImageButton如何让图片按比例缩放不被拉伸
  6. poj 2559 Largest Rectangle in a Histogram (单调栈)
  7. ltrace killed by SIGTRAP
  8. chgrp命令
  9. css首行缩进两个字符串
  10. hdu Color the ball
  11. uptime命令具体解释——linux性能分析
  12. 201521123070 《JAVA程序设计》第12周学习总结
  13. Linux端口被占用的解决(附Python专版)
  14. springboot 项目中读取资源文件内容 如图片、文档文件
  15. python 模块之platform模块(基本了解)
  16. pytest文档21-pytest-html报告优化(nodeid中文显示[\u6350\u52a9\u6211\u4eec]问题解决)
  17. 深入浅出SharePoint2012——安装Report Service
  18. java中error和exception
  19. BZOJ1086 SCOI2005王室联邦
  20. 九度OJ 上剑指 offer 习题目录

热门文章

  1. win10下载软件防止被杀
  2. Java基础篇 - 强引用、弱引用、软引用和虚引用
  3. Oscar的数理统计笔记本
  4. 阿里云zabbix的python脚本
  5. 【Java杂货铺】JVM#Java高墙之内存模型
  6. 36)PHP,搜寻数据库信息在html中显示(晋级1)
  7. 《C程序设计语言》练习 1-8,1-9
  8. iOS燃烧动画、3D视图框架、天气动画、立体相册、微信朋友圈小视频等源码
  9. iOS 开发中有关pch文件,以及pch常用的内容
  10. 认识shell