LoadRunner testing MySQL to perform an insert operation

Source: Internet
Author: User

Create a new table under a database

CREATE TABLE TT (
ID INT not NULL PRIMARY KEY auto_increment,//Main table index, self-increment
' Name ' VARCHAR (20)
)

Storage mode

ALTER TABLE < table name > engine = InnoDB;

--------------------------------------------------------------------------

int db_connection;

Vuser_init ()
{
char** Result_row;
Char *server = "xxx.xx.x.xx"; The IP address of the database
Char *user = "ceshi001"; Database Access User Name
Char *password = "12345678"; Password
Char *database = "Ceshi"; Database name
int port = 3306; Access Port

int unix_socket = NULL;
int flags = 0;

int RC;
int index = 0;

rc = Lr_load_dll ("D:\\libmysql.dll"); Unpacking the package, please set your own directory

if (rc!=0)
{
Lr_error_message ("Load MySql.dll error!");
Lr_abort ();
}

Db_connection = Mysql_init (NULL);

if (db_connection = = NULL)
{
Lr_error_message ("Insufficient memory");
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 0;
}

Action ()
{
int RC;
char** insertsql[222];
strcpy (Insertsql, "INSERT into TT (name) VALUES (' xxx ')");
Lr_start_transaction ("Insert");
rc = mysql_query (db_connection,insertsql);
Lr_end_transaction ("Insert", Lr_auto);
return 0;
}

Vuser_end ()
{
Mysql_close (db_connection);
return 0;
}

LoadRunner testing MySQL to perform an insert operation

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.