2 Minutes To Code (β Version)

JMeter - 2 minute tutorial

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:
  1. 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]

  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]

  3. 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]

  4. 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.

  5. 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]

  6. 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]

Image 1 : Add a thread-group. Top of page


Image 2 : Give a name to thread-group. Top of page


Image 3 : Add a JDBC Request Sampler Top of page


Image 4 : Give a name to JDBC Sampler, pool Name and Query. Top of page


Image 5 : Add a config element JDBC Request Defaults" Top of page


Image 6 : Configure JDBC Request Defaults Top of page


Image 7 : Add the listener "View Results in Table" Top of page


Image 8 : Give a name to listener and run the test. Top of page


Image 9 : Check result of test. Top of page