简体   繁体   中英

How to retrieve data using a db connector in ESB

在此处输入图片说明

I am trying to retrieve names of employees from the database by calling a stored procedure and logging it. But Instead of the names , this is the output of the log:

INFO  2019-12-11 11:48:39,994 [[MuleRuntime].cpuLight.10: [testrun].testrunFlow.CPU_LITE @3bc66a50] [event: 0-12970c00-1bde-11ea-92a5-38dead78b440] org.mule.runtime.core.internal.processor.LoggerMessageProcessor: 
org.mule.runtime.core.internal.message.DefaultMessageBuilder$MessageImplementation
{
  payload=org.mule.extension.db.internal.result.statement.CloseableMap@8194c34
  mediaType=application/java; charset=UTF-8
  attributes=<not set>
  attributesMediaType=*/*
}

what changes can I make so that I recieve the list of names from db.

your database connector by defaults returns a resultset. convert your resultset into a json by adding a transformer after DB call and set output type to json. if you want only one particular field then you need to have your transform done accordingly

在此处输入图片说明

在此处输入图片说明

as you can see in your logger that its mentioned the payload type payload=org.mule.extension.db.internal.result.statement.CloseableMap@8194c34

that is the internal representation of the result set read back from the stored procedure. so just convert it into json or whatever format you want. Put a transform message component after DB call and do the following:

%dw 2.0
output application/json
---
payload

if you want any particular field or something then you can see how your payload is getting structured and do the dataweave accordingly

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM