LoadRunner How to connect to an Oracle database
Recently doing a test database performance project, directly write out the connection database and database query and insert the script
In Vuser_init (connect to database)
#include "Lrd.h"
Static Lrd_init_info Initinfo = {Lrd_init_info_eyecat};
Static lrd_default_db_version dbtypeversion[] =
{
{Lrd_dbtype_none, Lrd_dbversion_none}
};
Static Lrd_connection * CON1;
Static Lrd_cursor * CSR1;
Vuser_init ()
{
Lrd_init (&initinfo, dbtypeversion);
Lrd_open_connection (&con1, lrd_dbtype_oracle, "username", "password", "Service Name", "", 0, 0, 0);
}
Action (for database operations)
Action ()
{
Lr_start_transaction ("INSERT");
Lrd_open_cursor (&CSR1, Con1, 0);
Lrd_open_cursor (&CSR1, Con1, 0);
Lrd_stmt (CSR1, "SQL statement",-1, 0, 1, 0);
Lrd_exec (CSR1, 0, 0, 0, 0, 0);
/*
PrintRow2, 0);
Lrd_close_cursor (&CSR1, 0);
*/
Lrd_commit (0, Con1, 0);
Lr_end_transaction ("INSERT", Lr_auto);
}
Vuser_end (freeing resources, shutting down the database)
Vuser_end ()
{
Lrd_close_connection (&con1, 0, 0);
Lrd_end (0);
return 0;
}
LoadRunner How to connect to an Oracle database