To connect to a database, you add a connection step, lr_db_connect, to your script through the Steps Toolbox. A built-in Connection String Generator guides you in creating a connection string specific to your database and credentials. You can also test your connection before inserting the step.
When running your script with iterations, virtual users only repeat the Action section of the script. If you include the database connection step in the Action section, the test will repeat it for each iteration. Virtual Users only repeat the Action section of the script, but not the vuser_init or vuser_end sections. Therefore, we recommend that you place the database connection step in the vuser_init section, and the disconnect step, lr_db_disconnect in the vuser_end section.
In cases where you only need to do one query and scroll through the data, you should also place the query statements in the vuser_init section.
For additional tips for working with Web services, see How to Send Messages over JMS.