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
Mysqlfunc.c的更多相关文章
- FTS5与DIY
此文已由作者王荣涛授权网易云社区发布. 欢迎访问网易云社区,了解更多网易技术产品运营经验. FTS5简介 前文已经介绍了FTS3/FTS4,本文着重介绍它们的继任者FTS5. FTS5是在SQLite ...
- APUE之第5章——标准I/O库
一.知识回顾:文件I/O 文件 I/O 是不带缓冲的 I/O(unbuffered I/O),指每个 read 和 write 都调用内核中的一个系统调用. 对于内核而言,所有打开的文件都通过文件描述 ...
随机推荐
- [ZOJ 3076] Break Standard Weight
题目连接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5009 题意:给你两个数字,可以把其中一个拆成两个数字,计算这三个数字 ...
- K nearest neighbor cs229
vectorized code 带来的好处. import numpy as np from sklearn.datasets import fetch_mldata import time impo ...
- 在RecyclerView中集成QQ汽泡二
上次已经将GooView集成到RecyclerView当中了[http://www.cnblogs.com/webor2006/p/7787511.html],但是目前还有很多问题,下面先来运行看一下 ...
- 使用CreateWindowEx创建子窗口的注意事项
比如: 使用 HWND child = CreateWindowEx(0,L"childclass",NULL,WS_CHILD | WS_VISIBLE | WS_CLIPSIB ...
- axios时遇到的Request Method: OPTIONS
前言 在请求axios 请求数据的时候,会出现options的,是因为请求是分为简单请求和复杂请求. 简单请求 满足下面两个条件的请求是简单请求: 请求方式是以下三种之一: HEAD GET POST ...
- for update的作用和用法
一.for update定义 for update是一种行级锁,又叫排它锁,一旦用户对某个行施加了行级加锁,则该用户可以查询也可以更新被加锁的数据行,其它用户只能查询但不能更新被加锁的数据行.如果其它 ...
- [React] Always useMemo your context value
Have a similar post about Reac.memo. This blog is the take away from this post. To understand why to ...
- 【Andriod-AlertDialog控件】 弹出对话框AlertDialog用法
Result: Code: import android.app.Activity; import android.app.AlertDialog; import android.content.Di ...
- keras中常用的初始化器
keras中常用的初始化器有恒值初始化器.正态分布初始化器.均匀分布初始化器 恒值初始化器: keras.initializers.Zeros() keras.initializers.Ones() ...
- python Print 输出
print 默认输出是换行的,如果要实现不换行需要在变量末尾加上逗号 , #!/usr/bin/python # -*- coding: UTF-8 -*- x="a" y=&qu ...