Highlighted
Absent Member.
Absent Member.
1383 views

LoadRunner Script insert only 40 Records

Hi All,

I am Ravi i am new to LoadRunner....
i have issue i had record a script of my application to create record in database i have make chagnes in that script to insert more than 100 record from one script run,
Script execute successfully but it insert only 40 records in database in every run i have notice that it insert only 40 records in database.

i want to insert more then 1000 records from one script run...

please suggest any idea where it is going wrong....

Thanks in Very Advance 🙂
0 Likes
8 Replies
Highlighted
Absent Member.
Absent Member.

Re: LoadRunner Script insert only 40 Records

Hi,

1. What changes have you made in the script to insert more than 100 records?

2. Are you running the script for multiple iterations or one iteration?

3. Did the script run successfully?

Warm Regards,
Muhammad Abrar
0 Likes
Highlighted
Absent Member.
Absent Member.

Re: LoadRunner Script insert only 40 Records

Thanks friend for your Reply.....

as per your questions

1) I have add lr_think_time(120); after every 40 articulo inserted in Script, i make this change to add a PAUSE after every 40 articulo.

2) I run script in one iteraction only.

3) And yes script executed successfully....
0 Likes
Highlighted
Absent Member.
Absent Member.

Re: LoadRunner Script insert only 40 Records

Well, I do not correctly understand how the script is modified. If the original script runs fine and creates one record per iteration, can you try to run the script for multiple iterations and see if multiple records (equal to the number of iterations) are created?

Warm Regards,
Muhammad Abrar
0 Likes
Highlighted
Absent Member.
Absent Member.

Re: LoadRunner Script insert only 40 Records

Hi Abrar,

Script i have that contains 500 Record insert script when i run this script it executes in one interaction only and insert first 40 records in database....

so are you talking about that if i want to insert 500 then i have to make it in 500 iteration, but i have a script that contains script of that 500 record in one script file ony....

please suggest you opinios...

Thanks
0 Likes
Highlighted
Absent Member.
Absent Member.

Re: LoadRunner Script insert only 40 Records

Ravi,

As Abrar had stated, why dont you try recording a script to insert 1 record in the db, and then, run the same by increasing the number of iterations to 100 (or whatever number of records you want in the db) and run the same.
Let us know if this works.
0 Likes
Highlighted
Absent Member.
Absent Member.

Re: LoadRunner Script insert only 40 Records

Actualy i have a more than 100 records that i read from excel file and create loadrunner script of that and execute that script in loadrunner.

that all 100 records contains different data/property.

so as you have mention iteration in that how can i do this to insert more than 100 records with different data ??

i want in that way it should inserted in one run only if possible with that no of iteraction that is fine but there should not be requirment like that to change parameter data manualy in each iteration because there is lots of data inserted in one record and so on for 100 recoreds.


please suggest.....
0 Likes
Highlighted
Absent Member.
Absent Member.

Re: LoadRunner Script insert only 40 Records

I have one suggestion, i dont know it will be success full or not,

Y dont u decrease the think time.. say lr_think_time(120) to Lr_think_time(10) /

I dont know y u want to pause???

May be this is bec of "time out b/w the db and the scripts"

Just try this..

Instead of pausing u can comment after 40 records.. so that u can check in ur replay logs
0 Likes
Highlighted
Absent Member.
Absent Member.

Re: LoadRunner Script insert only 40 Records

hi,

below is the script to fetch and insert records from ORACLE or MYSQL database. The script working fine for Fetch records but shows error and failed for INSERT RECORDS...!!
can anybody please help.???

/*
* LoadRunner Java script.
* Description: Oracle Database Testing via JDBC
*/

import lrapi.lr;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.*;

public class Actions
{
// Create global connection variable
private Connection connection;

// VUser Init
public int init() throws ClassNotFoundException, SQLException
{
// Initialize DB connection
//connection = null;
try
{
/*// Load Oracle JDBC Driver*/
/*Class.forName("oracle.jdbc.driver.OracleDriver");*/

// Load MySQL JDBC Driver
Class.forName("com.mysql.jdbc.Driver").newInstance();

}
catch (Exception ex)
{
// If driver load is unsuccessful
lr.log_message("Database Driver not found");
lr.abort();
}
try
{
// Specify the JDBC Connection String (jdbc:oracle:thin:@HOST:PORT:SID)
/*String url1 = "jdbc:oracle:thin:@headwired:1521:SID";*/
String url2 = "jdbc:mysql://localhost:3306/test";
String username = "root";
String password = "1234";

// Connect to URL using USERNAME and PASSWORD
connection = DriverManager.getConnection(url2,username,password);
lr.log_message("JDBC Connection Successful");
}
catch (SQLException e)
{
// If Connection Failed
lr.log_message("Database Connection Failed, Please check your connection string");
lr.abort();
}
return 0;
} //end of init

public int action() throws ClassNotFoundException, SQLException
{
// Database Query Insert Records
lr.start_transaction("Database_Query_Insert_Records");
database_query("INSERT INTO student(id,name)VALUES('A105','Hitesh')");
lr.end_transaction("Database_Query_Insert_Records", lr.AUTO);

// Database Query Fetch Records
lr.start_transaction("Database_Query_Fetch_Records");
database_query("select * from student");
lr.end_transaction("Database_Query_Fetch_Records", lr.AUTO);

return 0;
} //end of action

public int end() throws Throwable
{
connection = null;
return 0;
} //end of end

// Function: database_query
// Argument: SQL Query String
// Performs an SQL Query String, and returns pass or fail for the current transaction
//
public int database_query(String SQL_QUERY)
{
Statement stmt = null;
ResultSet rset = null;

try
{
connection.setAutoCommit(false);
stmt = connection.createStatement();
rset = stmt.executeQuery(SQL_QUERY);
lr.set_transaction_status(lr.PASS);
while (rset.next())
{ // Print the results of the query
lr.log_message(rset.getString(1));
lr.message("\t");
lr.log_message(rset.getString(2));
lr.message("\n"); // Note: This should be used for debugging only,
} // as it slows down execution time
lr.log_message("SQL Query Executed Successfully");
rset.close();
}
catch (SQLException e)
{
// SQL Query has failed
lr.log_message("Caught Exception: " + e.getMessage());
lr.set_transaction_status(lr.FAIL);
return 1;
}
return 0;
}
}
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.