0
votes

I have very simple application using mule. this application should retrieve some value from DB defined by value (name of person) send by http request. I used the example used here: https://docs.mulesoft.com/mule-user-guide/v/3.6/database-connector-examples

My flow:

<http:listener-config name="HTTP_Listener_Configuration_DB2"
        host="localhost" port="8092" doc:name="HTTP Listener Configuration" />
    <flow name="database_connector_mysql2Flow">
        <http:listener config-ref="HTTP_Listener_Configuration_DB2"
            path="/*" doc:name="HTTP" />
        <db:select config-ref="MySQL_Configuration" doc:name="Database">
            <db:parameterized-query><![CDATA[select Id, name, lastname, Email, phone from employee where name=#[message.inboundProperties['name']];]]></db:parameterized-query>
        </db:select>
        <json:object-to-json-transformer doc:name="Object to JSON"/>
    </flow>

After running the application, I set the following url in the browser:

http://localhost:8092/?name=Karam

But all what I get is only empty bracket [ ]

I am suspecting this part of mySql query is not correct:

where name=#[message.inboundProperties['name']]

Any help?

2

2 Answers

0
votes

Use dynamic-query instead of parameterized query.

0
votes

Did you run the script at https://docs.mulesoft.com/mule-user-guide/v/3.6/database-connector-examples

Do you have name column in your employee table? And do you have any records for name 'Karam'?

change the query to where name=#[message.inboundProperties.'http.query.params'.name]