mysql中func什么意思_Mysqlfunc.c

int rc;

int db_connection;

char *server = "192.168.139.207"; // 数据库的ip地址

char *user = "cloud"; // 数据库访问用户名

char *password = "cloudtest"; // 密码

char *database = "sklCloud"; // 数据库名称

int port = 3306; // 访问端口

int unix_socket = NULL;

int flags = 0;

char** result_row;

int query_result;

char szSql[256];

int MySqlInit()

{

rc = lr_load_dll("libmysql.dll");

db_connection = mysql_init(NULL);

if (db_connection == NULL)

{

lr_error_message("Insufficient memory");

lr_abort();

}

if(rc!=0)

{

lr_error_message("Load MySql.dll Error!");

lr_abort();

}

rc = mysql_real_connect(db_connection,server, user, password, database, port, unix_socket, flags);

if(rc == NULL)

{

lr_error_message("connect mysql error! %s",mysql_error(db_connection));

mysql_close(db_connection);

lr_abort();

}

return rc;

}

int MySqlUnit()

{

// 释放MySQL资源

mysql_close(db_connection);

return 0;

}

int InsertValue(char* query)

{

rc = mysql_query(db_connection,query);

if (rc != 0)

{

lr_error_message("%s", mysql_error(db_connection));

}

query = NULL;

return rc;

}

int MySqlQuery(char* szSql)

{

rc = mysql_query(db_connection,szSql);

if(rc != 0)

{

lr_error_message("%s",lr_eval_string("?"));

lr_error_message("%s", mysql_error(db_connection));

szSql = NULL;

return -1;

}

query_result = mysql_use_result(db_connection);

if (query_result == NULL)

{

lr_error_message("%s", mysql_error(db_connection));

mysql_free_result(query_result);

szSql = NULL;

return -2;

}

result_row = (char **)mysql_fetch_row(query_result);

if (result_row == NULL)

{

lr_error_message("Did not expect the result set to be empty");

mysql_free_result(query_result);

szSql = NULL;

return -3;

}

mysql_free_result(query_result);

szSql = NULL;

return 0;

}

可将mysqlfunc.c copy到脚本路径下,在globals.h中引用:

// Include Files

#include "lrun.h"

#include "lrd.h"

#include "web_api.h"

#include "lrw_custom_body.h"

#include "my_api.c"

#include "mysqlfunc.c"

安装mysql dll库:

MySQL LoadRunner libraries.zip

解压后

将bin下的dll文件copy到:

D:\Program Files\HP\LoadRunner\bin

将include下的文件copy到:

D:\Program Files\HP\LoadRunner\include

MySQL LoadRunner libraries下载:

http://pan.baidu.com/s/1pL6tNvX

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值