Get Knowledge from Video instead of Content:

Monday 30 January 2017

JMeter - PreProcessor - "JDBC PreProcessor"

JDBC PreProcessor is used to fetch the data from the database which can be used in the sampler's request. Let's try to understand with an example. Consider you have a performance testing scenario where customer needs to cancel the existing order. The order number is available in the database against customerID. So, your approach would be to get the orderID using customerID from the database and send the order cancel request.

Once you add JDBC PreProcessor under cancel request, it executes the select query to fetch orderID and then pass this value to cancel request sampler.

To use JDBC PreProcessor in the script, firstly you need to set-up the JDBC connection with the database. For this purpose, you need to add JDBC Connection Configuration element under Test Plan (if you have more than 1 thread and use the same database configuration). Refer the link to get more information on JDBC Connection Configuration.
Add JDBC PreProcessor under the sampler for which you need data from the database.    
Write down the SQL statement inside SQL Query section
Run the test and see the result

How to add "JDBC PreProcessor" element?
You can follow the below steps:
1. Select the "Thread Group", "Controller" or "Sampler" node (where you want to fetch the data).
2. Right-click on the node
3. Mouse hovers "Add"
4. Mouse hovers "PreProcessor"
5. Click "JDBC PreProcessor"

How to remove "JDBC PreProcessor" element?
You can follow the below steps:
1. Select "JDBC PreProcessor" node
2. Right click on "JDBC PreProcessor" node
3. Click "Remove" (Mouse) or "Delete" button from the keyboard
4. Click "Yes"    

What are the attributes of "JDBC PreProcessor" element?

"JDBC PreProcessor" has following attributes:
  • Name: To provide the name of the preprocessor
  • Comments: To provide arbitrary comments (if any)
  • Variable Name of Pool declared in JDBC Connection Configuration: The name of the connection pool given in the JDBC Connection Configuration.
  • Query Type: Choose the type of SQL query statement like Select, Update, Callable, Commit, Rollback etc.
  • Query: In this section, you can write down the SQL statement which is used to perform the operation before the sampler executes.
  • Parameter Values: If parameters are used in the SQL query then parameter values can be provided here. Parameter values must be comma separated and in the order as same as they are used in the SQL statement.
  • Parameter Types: The parameter type of the values defined in the 'Parameter Values' field like VARCHAR, INTEGER etc. They are also comma separated and in the same order as parameter values are written.
  • Variable Names: The list of the variables in which fetched data from the database will be stored. Variable names are also in comma separated format.
  • Result Variable Name: The key-values variable in which data-set value is stored. This is an optional attribute.
  • Query Timeout (s): JMeter waits for query response until given timeout (in seconds) reaches.
  • Handle ResultSet: The process, how the fetched result will be handled like Stored as String, Stored as Object etc.
Next Topic:
Apache JMeter - "JSR223 PreProcessor" Element

Previous Topic:
Apache JMeter - "HTTP URL Re-writing Modifier-" Element

Related Topics:

No comments :

Post a Comment