Overview

Apache JMeter may be used to test performance both on static and dynamic resources, Web dynamic applications.
It can be used to simulate a heavy load on a server, group of servers, network or object to test its strength or to analyze overall performance under different load types.

Why do we need BeanShell in JMeter

BeanShell is one of the most advanced JMeter built-in components. It supports Java syntax and extends it with scripting features like loose types, commands, and method closures. If your test case is uncommon and implementation via embedded JMeter components becomes tricky or even impossible, BeanShell can be an excellent option to achieve your objectives.

BeanShell entities in JMeter have access to both internal JMeter APIs and any external classes that are loaded into the JMeter classpath (be sure to drop necessary jars into /lib/ext folder of your JMeter installation and place all necessary “import” statements at the top of your BeanShell scripts).

BeanShell Sample Snippet

  1. Open Apache Jmeter.

2.  Add Thread Groupd [Test Plan -> Add -> Threads (Users) -> Thread Group]

3. Add BeanShell Sampler [Thread Group -> Add -> Sampler -> BeanShell Sampler]

4.  Rename BeanShell Sampler name to “Select Query”

5. Code snippet to read from table

 

6.  Select Log Viewer panel as shown in Screen shot & Run Script.

 

 

Also find below code snippet to insert data into table