Mysql 根据Mule中http中的属性send从数据库中获取值
我有一个非常简单的应用程序使用mule。这个应用程序应该从由http请求发送的人的值名定义的数据库中检索一些值。 我使用了这里使用的示例: 我的流程:Mysql 根据Mule中http中的属性send从数据库中获取值,mysql,mule,Mysql,Mule,我有一个非常简单的应用程序使用mule。这个应用程序应该从由http请求发送的人的值名定义的数据库中检索一些值。 我使用了这里使用的示例: 我的流程: <http:listener-config name="HTTP_Listener_Configuration_DB2" host="localhost" port="8092" doc:name="HTTP Listener Configuration" /> <flow name="database_
<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>
但我得到的只是空括号[]
我怀疑mySql查询的这一部分不正确:
其中name=[message.inboundProperties['name']]
有什么帮助吗?您是否在运行脚本 在employee表中是否有name列?你有名字“Karam”的记录吗 将查询更改为
其中name=[message.inboundProperties.http.query.params.name]使用动态查询而不是参数化查询。我使用另一个数据库。如果我使用以下查询,我也会记录“Karam”的名称:选择Id、姓名、姓氏、电子邮件、来自name='Karam'的员工的电话;它毫无问题地工作。当我使用where name=[message.inboundProperties['name']]时,唯一的问题出现了;这就是答案中所说的。。。您正在传入查询参数http://localhost:8092/?name=Karam 在sql查询中,您使用的是无法使用的inboundProperties。。。使用[message.inboundProperties.http.query.params.name]instead@AnirbanSenChowdhary非常感谢。这就解决了问题
http://localhost:8092/?name=Karam