1
votes

I'm working with JMeter to load test queries on a mySQL database (memsql server, mySQL syntax). I'm using a gui version of JMeter to create a test plan xml file and then go to another server and run that xml in non-gui mode.

I have two queries running, one that selects and one that inserts. Both queries use parameters taken from a csv file I made with a script. My SELECT statement works just fine with parameters taken from a csv file but I run into syntax errors with my INSERT statement:

INSERT INTO customer_transactions_current (`column_name1`, ... , `column_name12`)
VALUES ((${r1},${r2},${r3},${r4},${r5},${r6},${r7},${r8},${r9},${r10},${r11},${r12}));

In the section of the query in the gui mode under 'CSV Data Set Config' I choose to delimit the data by ',' and the variable names are r1,..,r12. Under the query itself I entered the parameter types and again the same names, just as I did for the working SELECT query.

When I run the query I run into a syntax error on the first column (which is of type datetime):

java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '19:00:00,75400492,936988,56,1115,5,2156,8,2,3,909,3))' at line 2

The dates I'm entering are of the form: '2018-11-2 20:00:00' and in the csv file they are present without apostrophes.

It seems that the syntax error has something to do with the date and in the position where it holds a space. I tried entering the STR_TO_DATE function for that column but kept getting syntax errors. BUT when I try to take some values from the file and manually run the query it works fine! So my thoughts are that it has something to do JMeter's conversion of spaces before sending out the query.

Is the problem with my configurations of JMeter? Since the query is OK manually.

1
Use back-ticks to delimit the column names.jarlh
@jarlh Thanks, I did in the original query. I'll edit it here.Nexaspx

1 Answers

1
votes

Add apostrophes to insert and remove unnecessary parenthesis

INSERT INTO customer_transactions_current ('column_name1', ... , 'column_name12')
VALUES ('${r1}','${r2}','${r3}','${r4}','${r5}','${r6}','${r7}','${r8}','${r9}','${r10}','${r11}','${r12}');

If you have date issue see using STR_TO_DATE