Usage of JDBC Sampler for basic database test
Let's write our first database test plan for testing queries using jdbc. So here are the steps. The screenshots are provided below.
The steps are as follows:
The steps are as follows:
- Right click on Test Plan in left-hand side pane. And add a thread group. In the right-hand side pane, set a name for thread-group (eg. JDBC Test). Keep default values in other fields. There is no save or update button. Any changes you make are instantly applied when you move away from the eleent.
[Image 1 and Image 2] - Now, right-click on the thread-group created above, and add Sampler JDBC Request. In the the right-hand pane, add a name for the sampler (eg. JDBC Request), in the pool name field, put myPool (we will reuse the pool name when defining JDBC Config Defaults). In the Query Type field, retain the default value "Select Statement". In teh duwery field, put the query you want to test.
[Image 3 and Image 4] - Now let's configure the database url, driver etc. Righ-click of "Test Plan" in left-hand side pane and add Config Element JDBC Request Defaults. In this jdbc config element, add the pool name (same name myPool used above )db url driver name, username and password as shown in the image. Keep the default values in other fields.
[Image 5 and Image 6] - Since JMeter will execute queries using JDBC, we need to provide the database specific driver class to JMeter's classpath $JMETER_HOME/lib. You will need to restart JMeter after adding this jar file for the classpath to get reloaded.
- Now in order to view the test results, you need a Listener. We will use a tabular listener. Right click on Test Plan and add Listener View Results in Table. Give it a name and let other fields keep default value.
[Image 7 and Image 8] - You are done now. Just hit the start button (green arrow head) from the menu bar. In the View Results in Table page, the result will be displayed. It will contain timestamp, response time, response size in bytes etc.
[Image 9]