Is it possible to generate random double numbers in JMeter?

I tried to use the Random in the config element where i have defined the

Minimum value: 47.9999  (RND1)
Maximum value: 30.9999  (RND2)

Then in the selected Prepared Selected Statement i placed this values:

Parameter values: ${RND1},${RND1},${RND2}

But it seems not work, because i receive an error:

Response message: java.sql.SQLException: Cannot convert class java.lang.String to SQL type requested due to java.lang.NumberFormatException - For input string: "${RND1}"

1 Answer 1


Looks like ${RND1} is not expanded to it's value in your JDBC Request because it wasn't initialized Random Variable config item - because the last one is to generate only integer values (as well as jmeter's __Random function).

To generate random double values in defined range you can use schema like below:

1. Define MIN and MAX range values as variables in User Defined Variables

RND1    37.9999
RND2    41.9999
2. Generate random double value in range RND1..RND2 using e.g. Beanshell Sampler:

  • Parameters: ${RND1},${RND2}
  • Script (java code):
import java.util.*;

String [] params = Parameters.split(",");

double rangeMin = Double.valueOf(params[0]);
double rangeMax = Double.valueOf(params[1]);
Random r = new Random();
double randomValue = rangeMin + (rangeMax - rangeMin) * r.nextDouble();



Adding Debug Sampler, with Jmeter variables = true let you see generated values for debugging purposes.

3. Refer generated random value as ${RND} for further use (in JDBC Request in your case)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.