When using parameterization, LoadRunner usually needs to prepare a large amount of data. Therefore, LoadRunner provides two parameterized values: manual editing and database connection. Generally, during the stress testing of large business concurrency, the data volume is certainly very large, so it is impractical to manually edit it. Fortunately, the database connection function is available, which makes it much easier. However, the database connection function is not provided to facilitate data retrieval. More importantly, the database creation function should be used through simple SQL statements, you can complete a large amount of reusable data, which is the power of the database.
After parameterization is set in the script, you can find a tag button data wizard after entering the parameterization attribute. Here is the interface for connecting to the database. However, you cannot directly connect to a database. You Need To Use ODBC provided by windows to bridge the connection. Here, SQL server2005 is used as an example. Find the management tool on the control panel of the system, and then click the data source (ODBC) to enter. Under the system DNS tab, add the data source and select sqlserver ,:
After the configuration is complete, perform a simple configuration test. After the test is successful, the ODBC bridging is successful. Next, you can create a database and a table. Here, you can create a table table_a under sqlserver2005 with only one field named A. Insert 100 records to the table using the following SQL script:
Declare @ A int;
Set @ A = 1;
While @ A <= 100
Begin
Insert into DBO. table_a values ('test ');
Set @ A = @ A + 1;
End
After the above script is executed, the table inserts 100 identical records "test", and the data in the table is ready for OK.
Return to LoadRunner vuser and create a simple parameterized script as follows:
Action ()
{
Lr_eval_string ("{testparam }");
Return 0;
}
Right-click parameters in the parameter properties dialog box, click data Wizard to enter the database connection configuration, select "spectoffsql statement Manu" to create an SQL connection, select next, and then click Create to enter the data source selection method, select the data source named by LoadRunner, as shown in:
In the blank area of the following SQL statement, enter the corresponding SQL statement to complete the appropriate data import. After the data is imported to the parameterized list, as shown in:
The most important preparation for performance testing is data, especially the flexible use of databases, which will greatly improve the efficiency of performance testing.