Home > Back-end >  How can I join table to the variable in Jmeter for testing database
How can I join table to the variable in Jmeter for testing database

Time:03-21

I have I have two different server connections (2 JDBC Connection Configuration)

  1. From the first server I get data from the table and in Jmeter create variable 'prod' and store it as a string enter image description here

In view result tree 'Response data' I have columns and rows as expectedenter image description here

  1. In the second server I want to join one table to the data from the first server connection using SQL below: enter image description here When I look in 'Response data' of Result tree I have this mistake: 'The identifier that starts with '{Locale=es, Position=null,CREATED_BY_Orign=null, CREATED_DATE=2020-02-11 16:30:55.199' is too long. Maximum length is 128.'

Question: Can I use a variable to join one table to another? OR I need to create a table in the second server and populate it with data from the first server variable? If so, could you please explain how to do it?

P.S. Servers are not linked and can't be

CodePudding user response:

Sorry for being late, since I don't use that it took some time to do configuration done, Anyways let me descript what I am doing here, and how it can be done, starting from configuration I have 2 databases in my localhost, test, and stack I have created your scenario in which tbl_Student sid, sName has some info from another database test, tbl_info with idinfo, uid, info, now I want to get info for each student.

I am using left join, here I am telling MySQL to give me all records from tbl_Student but I don't care if we have null in tbl_info

select 
stcak.tbl_student.sid, stcak.tbl_student.sName,test.tbl_info.info 
from 
stcak.tbl_student left join test.tbl_info 
on (stcak.tbl_student.sid = test.tbl_info.uid)

If you see in my query I have provided DB name also, Test and Stack

<dbname>.<tablename>.<colName>
stcak.tbl_student.sid

Just to tell you what is going on, all game-changer is from the configuration and specifically the username, as you know I am connecting with root which has the privileges for all databases, in my case Test and Stack, but if the database in different serves I saw something like HandleRequestSet which can be used to combine the response with other respons I think.

I have also provided some images, you can check from your end. Config Query Result Result Set

CodePudding user response:

We cannot provide a comprehensive answer because we don't know what you're going to do with this data next.

On JMeter level the result object is stored as List of Maps so you can implement the "join" using Groovy scripting.

See Debugging JDBC Sampler Results in JMeter article for more information.

  • Related