LoadRunner connecting MySQL Database

Source: Internet
Author: User
Tags mysql connection string sprintf

1. library file: Http://files.cnblogs.com/files/xiaoxitest/MySQL_LoadRunner_libraries.zip

Add to LoadRunner Bin directory and include directory, respectively 2, Vuser_init

#define MySQLServer "192.168.1.106"
#define MYSQLUSERNAME "Root"
#define Mysqlpassword "123456"
#define MYSQLDB "Test"
#define Mysqlport "3306"

#include "ptt_mysql.h"
Vuser_init ()
{
return 0;
}

3.Action

Action ()
{
Char sqquery[512]; Defines a character array to store the SQL statement for the query
int i;
MYSQL *mconn; MySQL connection string

Lr_load_dll ("Libmysql.dll");

Mconn = Lr_mysql_connect (MySQLServer, Mysqlusername, Mysqlpassword, MySQLdb, Atoi (Mysqlport));//Create Connection

sprintf (Sqquery, "select * from Test1;"); /Query Test1 table data
Lr_mysql_query (Mconn, sqquery);//Execute SQL statement

sprintf (Sqquery, "INSERT into Test1 VALUES (2, ' BB ', ' 222222 ');"); /Insert Data
Lr_mysql_query (Mconn, sqquery);

sprintf (Sqquery, "UPDATE test1 SET uname= ' aaa ' WHERE id=1; ");//change user name AA to AAA
Lr_mysql_query (Mconn, sqquery);

sprintf (Sqquery, "DELETE from Test1 WHERE id=1;"); /delete
Lr_mysql_query (Mconn, sqquery);

Disconnecting database connections
Lr_mysql_disconnect (Mconn);

return 0;
}

4.vuser_end

Vuser_end ()
{

return 0;
}

LoadRunner connecting MySQL Database

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.