Ruben Laguna's blog

Jan 2, 2007 - 2 minute read - apache enhanced jdbc jmeter sampler Uncategorized

JMeter JDBC Sampler

UPDATE2:: It seems that my bugreport has been reviewed and the patch I submitted is merged into the JMeter svn tree. I also submitted a couple of patches dealing with COMMIT behavior that also have been included into the svn tree. so I strongly advise to use the standard JDBC Sampler as it includes alll features of the Enhanced JDBC Sampler plus other corrections

UPDATE: It seems that the patch has been merged with the standard JMeter source code tree as SVN r528906. I think, however, that the change it’s not present yet in the 2.2 release you need to download the Nightly Build.

Some time ago I posted a bug report for Apache JMeter benchmarking utility (you can find my other jmeter bug reports here) . The bug report contains an enhancement of the current JDBC Sampler to allow JMeter to invoke PreparedStatements and also to change the way Callable Statements are handled to avoid performance problems when using some JDBC drivers (mainly Sybase). Because I don’t know if this bug report will ever be integrated in JMeter or when. I decided to release this “Enhanced JDBC Sampler” as a JMeter plugin.

The installation is quite simple just download EnhancedJdbcSampler.jar and put it in $JMETER_HOME/lib/ext. Once you restart JMeter you should see a new option under Add -> Samplers called “Enhanced JDBC Request”. It works just like the old JDBC Sampler (see docs on how to use JDBC sampler here and here).Don’t forget to add the jdbc drivers jar into the lib directory The difference with the conventional JDBC Sampler is that you now have more options under Query type and there are two new text boxes at the bottom of the page. In the first box,you write the param values, and in the second box you write the param types. See the image below for an example.

Enhanced JDBC Sampler Screenshoot

In this example there are two parameters: the literal 1 and the variable ${A}. (In this particular case the ${A} comes from a Counter). The type of both parameters is INT. Check the list of JDBC Types. Source code If you are interested in looking at the code you can download it. It an Eclipse project so you can import it to your workspace using “Import->Existing projects into workspace”. Or you can just unzip it and use Apache Ant to build the project.