jmeter-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Raihan Jamal <jamalrai...@gmail.com>
Subject Re: Insert JSON String using JMeter to database
Date Wed, 13 Feb 2013 06:53:56 GMT
Makes sense now. So if I am going with option 1, and If I am going to
insert, it should be like this right?

${__BeanShell(UUID.randomUUID().toString())}
,"{""lv"":[{""v"":{""regId"":null,""
user"":null,""Id"":996},""cn"":1}],""lmd"":1360185}"


First is for one column and second is for other column. right?


*Raihan Jamal*


On Tue, Feb 12, 2013 at 10:35 PM, Deepak Shetty <shettyd@gmail.com> wrote:

> Option 1 :
> {"lv":[{"v":{"regId":null,"
> user":null,"Id":996},"cn":1}],"lmd":1360185} should become
>
> "{""lv"":[{""v"":{""regId"":null,""
> user"":null,""Id"":996},""cn"":1}],""lmd"":1360185}" i.e. replace all
> occurences of " by "" and quote the whole string.
>
> if you are using beanshell then just use the replaceAll function of a
> String to do the above replacement
>
> Option 2 (riskier):
> If you are absolutely certain that your JSON string cant contain an
> apostrophe '  then in the JDBC Request , change the type to update
> statement (instead of prepared update) and use something like
>
> INSERT INTO TEST2 (id, account) values ('${var1}', '${var2}')
> where var1 and var2 are the variables with the values you want to insert.
> If your json string (var2) doesnt have apostrophe then you dont need to do
> anything else since " is not special for sql
>
>
>
>
>
>
> On Tue, Feb 12, 2013 at 9:50 PM, Raihan Jamal <jamalraihan@gmail.com>
> wrote:
>
> > Thanks for the suggestion. But I am not sure, I understand what you said
> > just now. Can you provide me an example what changes I need to make in
> this
> > JSON string so that I can insert into the Database-
> >
> > *{"lv":[{"v":{"regId":null,"user":null,"Id":996},"cn":1}],"lmd":1360185}*
> >
> >
> > By that I will be able to understand much better.
> >
> > Thanks.
> >
> >
> > *Raihan Jamal*
> >
> >
> > On Tue, Feb 12, 2013 at 7:01 PM, Deepak Shetty <shettyd@gmail.com>
> wrote:
> >
> > >
> >
> http://jmeter.apache.org/usermanual/component_reference.html#JDBC_Request
> > >
> > > The list must be enclosed in double-quotes if any of the values
> contain a
> > > comma or double-quote, and any embedded double-quotes must be
> doubled-up,
> > > for example:
> > >
> > > "Dbl-Quote: "" and Comma: ,"
> > >
> > >
> > >
> > >
> > > On Tue, Feb 12, 2013 at 2:40 PM, Raihan Jamal <jamalraihan@gmail.com>
> > > wrote:
> > >
> > > > 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())}`*
> > > >
> > > > I am trying to insert `JSON String` into ACCOUNT columns using
> > `JMeter`.
> > > > Below is the JSON string that I am trying to insert.
> > > >
> > > >
> > >
> >
> *`{"lv":[{"v":{"regId":null,"user":null,"Id":996},"cn":1}],"lmd":1360185}`*
> > > >
> > > > In the parameter values section in JMeter, I am passing something
> like
> > > > this-
> > > >
> > > > *    ${__BeanShell(UUID.randomUUID().toString())}
> > > >
> > ,{"lv":[{"v":{"regId":null,"user":null,"Id":996},"cn":1}],"lmd":1360185}*
> > > >
> > > >
> > > > This is my SQL-
> > > >
> > > > *`INSERT INTO TEST2 (id, account) values (?, ?)`*
> > > >
> > > >
> > > > But after trying to insert, I am getting this exception-
> > > >
> > > >     Response message: java.io.IOException: Cannot have quote-char in
> > > plain
> > > > field:[{"]
> > > >
> > > > How can I fix this thing? I just need to insert JSON string in the
> > > `ACCOUNT
> > > > column`
> > > >
> > > > Any thoughts how to achieve this?
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > *Raihan Jamal*
> > > >
> > >
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message