Pass parameter in jdbc request in jmeter

214 Views Asked by At

In jdbc request, I have query where table name should be passed as parameter

Select * from '${b1}'

Below in jdbc request I have Parameter values as tablename1 Variable names as b1

But after executing query I am getting an error - incorrect syntax near '${b1}'

2

There are 2 best solutions below

0
Dmitri T On
  1. You cannot use a table or database name in a prepared statement

  2. Even if it would be valid you should modify your SQL query to look like:

    select * from ?
    

So instead of using "Parameter values" in the JDBC Request sampler you should set the variable using i.e. User Defined Variables and amend your SQL query to look like:

select * from b1

and JMeter in the runtime will substitute ${b1} JMeter Variable placeholder with its respective value:

enter image description here

1
user3278412 On

Instead of Select * from '${b1}' use Select * from ${b1} in your JDBC sample request.