Forum Discussion

Woutje's avatar
Woutje
New Contributor
4 years ago

Error java.lang.IllegalArgumentException: Parameter 'name' was not found in the SQL Query

I'm trying to write a query using predefined properties on TestCase level, but I keep getting an error when trying to execute the query. What is wrong with my query?

 

  • Hey Woutje,

    I dont typically use the properties from within a jdbc teststep, i normally use properties from a separate object so this is an educated guess but i noticed several things.

    Is the sql you want to execute actually a stored proc? If not, then uncheck the relevant tickbox

    Next with the values in your query it would appear everything is numeric cos you havent used quote marks surrounding you values. You need to check the datatypes of each of the table attributes you want e.g. your name attribute is likely gonna be a string/text, so the relevant value should be surrounded by quote...e.g. '${jdbcRequest#name}'

    Finally, however if you use properties from within a jdbc step the syntax is a little different (if you use properties from another object your syntax is fine, but not if the props are held in the jdbc step). Rather than use the prop expansion syntax like ${stepname#propname}, you use the propertyname with a colon suffix, e.g. :name

    So! Id change your query to look something like the following:

    Insert into employeeinfo (name, id, location, age, gender) values (':name', ':id', ':location', :age, ':gender);

    Note im guessing the age datatype is numeric.

    Make the changes and report back on progress and we'll sort. You should be good to go though!

    Ta

    Rich
  • richie's avatar
    richie
    Community Hero
    Hey Woutje,

    I dont typically use the properties from within a jdbc teststep, i normally use properties from a separate object so this is an educated guess but i noticed several things.

    Is the sql you want to execute actually a stored proc? If not, then uncheck the relevant tickbox

    Next with the values in your query it would appear everything is numeric cos you havent used quote marks surrounding you values. You need to check the datatypes of each of the table attributes you want e.g. your name attribute is likely gonna be a string/text, so the relevant value should be surrounded by quote...e.g. '${jdbcRequest#name}'

    Finally, however if you use properties from within a jdbc step the syntax is a little different (if you use properties from another object your syntax is fine, but not if the props are held in the jdbc step). Rather than use the prop expansion syntax like ${stepname#propname}, you use the propertyname with a colon suffix, e.g. :name

    So! Id change your query to look something like the following:

    Insert into employeeinfo (name, id, location, age, gender) values (':name', ':id', ':location', :age, ':gender);

    Note im guessing the age datatype is numeric.

    Make the changes and report back on progress and we'll sort. You should be good to go though!

    Ta

    Rich
    • Woutje's avatar
      Woutje
      New Contributor

      Hi Rich,

       

      Thanks for your feedback. In the meantime I had also discovered this. Id and age are indeed numbers. The rest are strings.

       

      KR

      Woutje