- JMeter
- Microsoft JDBC Driver for SQL Server
- IP address or domain name, port and database name which we would like to test
- User on SQL Server which have access to all required tables / stored procedures
- Be able to authenticate using SQL Server mode
- Some test data
Preparation
After you have downloaded all required packages, first thing is to unpack jmeter. Then unpack Microsoft JDBC Driver, go to sqljdbc_4.0\enu and copy sqljdbc4.jar into JMeter lib folder.
Configuring JMeter Solution
As usual, create new test plan with empty Thread Group. First thing which needs to be done, is to configure connection to MS SQL Server. To do this, add JDBC Connection Configuration which can be found in context menu under Add -> Config Element. When config element is added we need to put there previously prepared configuration data.
- Variable name: MSSQL_JDBC_Connection
- Connection string: jdbc:sqlserver://<IP>:<PORT>;DatabaseName=<DATABASE_NAME>;
- JDBC Driver class: com.microsoft.sqlserver.jdbc.SQLServerDriver
- Username and password
Next step is to configure JDBC Request element to execute some queries against SQL Server. We can add one by selecting from context menu Add -> Sampler -> JDBC Request. I propose to add also View Results Tree as child to JDBC Request sampler. It can be very useful in debugging.
First thing is to set option Variable name bound to pool to the same as Variable name set in JDBC Connection Configuration. In our case it will be MSSQL_JDBC_Connection
In my case, I will be using stored procedures for testing purposes.
Query Type must be set to Callable statement.
To execute stored procedure GetTestData from schema test with two parameters, following line needs to be added to Query text box:
{CALL test.GetTestData(?, ?)}
Query parameters can be passed using Parameter values and Parameter types options. My sample configuration looks like this:
Data for this test in my sample solution are loaded from CSV file. It contains list of comma separated values. First one is ID, second one is VALUE. My CSV Data Set config looks like this: This was the last step of configuration of sample solution. To start testing, configure thread group and click run :)
best and most helping article.
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteI am getting below error stored procedure GET_ELIGIBILITY_MSISDN
ReplyDeleteORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'GET_ELIGIBILITY_MSISDN'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
Dear Sagar,
ReplyDeleteIt looks like you are trying to adopt my tutorial to Oracle database, with witch I have very little experience and I won't be able to help you.
This comment has been removed by the author.
ReplyDeleteHi Piotr,
ReplyDeleteDo you know how it can be done if I am connecting to Oracle DB. I am trying to run a simple stored procedure from Jmeter but not able to do so. Have tried various options.
This is my stored procedure.
{call create_test_data('000000316F1422C8','N',1,'2016-01-28')}
http://stackoverflow.com/questions/35066074/running-stored-procedure-from-jmeter/35066586#35066586
thansk for the post!
ReplyDeleteIt's very useful.
ReplyDeleteI would like to load test on Big Stored procedure. That Store procedure itself taking more time, Calls several sps and consists of lot of rules.
So,In this case how do i do scripting?
Having problems with csv file. the stored proc calls goes through but he output is blank. Tested with same input in db and that works fine. Have tried using __CSVRead function and also by the way you showed, but for both output is blank. Please help
ReplyDeleteMy stored procedure takes a varchar parameter and returns it as bigint. How can I handle this through Jmeter? Plz also guide how can I declare a 'Date' type parameter?
ReplyDeleteyou're post is the best , maybe the only one that explain how to use the stored procedure in Jmeter, thank you!!
ReplyDelete