Using LoadRunner to test the performance of Oracle stored procedures

Source: Internet
Author: User
Tags oracleconnection


First you need to install LR. NET add-in, write code in the development environment, do a database connection, and then invoke the Execute stored procedure.



After installing, open the program, you should see the menu bar more than one:



Then add an LR project:






Then you can encode it, I wrote a code, as follows:



Using System;
Using System.Runtime.InteropServices;
Using System.ComponentModel;
Using System.Data;
Using System.Data.OracleClient;
Using Shangxin.data;
Using System.Collections;
Using System.Web;
Namespace Loadrunneruser
{
<summary>
Summary description for Vuserclass.
</summary>
[ClassInterface (Classinterfacetype.autodual)]
public class Vuserclass
{
Loadrunner.lrapi LR;
protected System.Data.OracleClient.OracleDataAdapter Oracleda;
protected System.Data.OracleClient.OracleCommand Loadcommand;
protected System.Data.OracleClient.OracleConnection OracleConnection;
   
Public Vuserclass ()
{
LoadRunner Standard API Interface:: Does not REMOVE!!!
LR = new Loadrunner.lrapi ();
}
Protected System.Data.OracleClient.OracleConnection getoracleconnection ()////sqlconnection
{
if (oracleconnection==null)
Oracleconnection=new System.Data.OracleClient.OracleConnection ();
oracleconnection.connectionstring= "User id=test; Password=write;data Source=escalade ";
return oracleconnection;
}
   
// ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
public int Initialize ()
{
To Do:add virtual user ' s initialization routines
return LR. Pass;
}
// ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
public int Actions ()
{
Try
{
Lr.start_transaction ("Testgetwithdraworderbycode");
System.Data.OracleClient.OracleConnection conn = new OracleConnection ("User id=test; Password=write;data Source=escalade ");
System.Data.OracleClient.OracleCommand comm = new OracleCommand ();
Comm. Connection = conn;
Comm.commandtext = "BILL." Getwithdraworderbycode ";
Comm.commandtype = CommandType.StoredProcedure;
Input parameters
System.Data.OracleClient.OracleParameter Param1=comm. Parameters.Add ("V_code", oracletype.varchar,20);
param1. Direction = ParameterDirection.Input;
param1. Value = "TH15";
Output parameters
System.Data.OracleClient.OracleParameter Param2=comm. Parameters.Add ("Retcursor", oracletype.cursor);
Param2. Direction = ParameterDirection.Output;
DataTable dt = new DataTable ();
Oracleda = new System.Data.OracleClient.OracleDataAdapter ();
Oracleda.selectcommand = comm;
Oracleda.fill (DT);
int Icount=convert.toint32 (dt. Rows.Count.ToString ());
if (icount>0)
Lr.end_transaction ("Testgetwithdraworderbycode", LR. PASS);
Else
Lr.end_transaction ("Testgetwithdraworderbycode", LR. FAIL);
}
catch (Exception ex)
{
String error = Ex. message;
}
return LR. Pass;
}
// ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
public int Terminate ()
{
To Do:add virtual user ' s termination routines
return LR. Pass;
}
}
}


Remember to add the necessary references, use the flexibility to grasp the specific


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.