0

I am working on the project in which I need to make a connection to database and insert lot of rows in that Database. I have two columns currently in that database-

ID         String PrimaryKey
ACCOUNT    String

So I need to insert lot of rows in these two columns with the help of JMeter. I am able to generate random Unique ID for ID column by using this-

${__BeanShell(UUID.randomUUID().toString())}

But how can I generate a Random JSON String for the ACCOUNT column?

Or Is there any way I can keep modifying the below JSON String every time whenever I try to insert in the database?

{"lv":[{"v":{"regId":null,"user":null,"Id":996},"cn":1}],"lmd":1360185}

Meaning for each thread whenever I am inserting into database, then in the above JSON string something should get modified for each thread and then get inserted in to the database.

Any thoughts how to achieve this?

1 Answer 1

1

Why not make a POJO for the JSON string and then with the constructor assign some random values to the properties. Then just serialize the POJO into JSON and write away.

That way you could write a loop that constructs your object and each construction would make an object that was slightly different than the last one.

Sign up to request clarification or add additional context in comments.

2 Comments

So all these are possible with JMeter? I am new to JMeter. Can you provide me a simple example to achieve my scenario?
Sorry I'm not familiar with JMeter. =( I just know it's used in Java environments and would imagine you could make a simple class and use that as part of JMeter. Look at Jackson (jackson.codehaus.org). You make a simple Java class, then use Jackson to turn it into JSON.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.