Now we are going to see how to configure, run and analyze the results of a test against a MySQL Database. This example is about MySQL but it can be done using any other kind of DB like Oracle, MongoDB or others.
- Install MySQL
If you do not have MySQL installed in your computer, you can download it from http://dev.mysql.com/downloads/ and install the MySQL server, it is very easy.
- Download the MySQL driver
Download mysql connector (
) and copy it in the lib directory of jmeter .- Start MySQL
Start the DB server so that you can make queries against it.
- Create database
You can create a database as you want, here is just an example of a very simple one:
- Create a test plan
Do the same actions as in the chapter before to create a test Plan using a new Thread Group, a new configuration element of the type JDBC configuration and a new request (sampler) of the type JDBC, add also a listener to parse and view the results in the same way as we did in the example before.
The only difference is the type of the sampler, in this case JDBC Sampler.
The only difference is the type of the sampler, in this case JDBC Sampler.
- JDBC Sampler
Give a meaningful name to the Variable Bound to Pool and write some SQL statement:
- JDBC Connection configuration
Add a new JDBC Connection Configuration to the sampler.
right click on the JDBC sampler -> add connection configuration
Change the parameters as follows:
- Save the plan and execute it.
- View the results using the listener configured before.
You can verify and check the output in the same way as in the HTTP request test plan, you can also add preprocessors, post processors, assertions or any other kind of element that you may need.
In this case the output is the results of the select statement.
You can use this kind of samplers for updating data as well by changing the SQL statement in the sampler configuration.
In the following screen capture is the basic information about the request response results: