Do you need to use the results from the DB as a Json?
If not, don't even bother converting the values to JSON before saving them to the sessionVars. Access them directly from the Payload after the DB call:



And here's the configuration XML:
<flow name="testsFlow">
<db:select config-ref="ORacle_DBCP_Config" doc:name="inputdata">
<db:parameterized-query><![CDATA[SELECT 'U001' AS USER_ID, 'Dharmin' AS USER_NAME FROM DUAL]]></db:parameterized-query>
</db:select>
<set-session-variable variableName="userName" value="#[payload[0].USER_NAME]" doc:name="userName"/>
<set-session-variable variableName="userID" value="#[payload[0].USER_ID]" doc:name="userID"/>
<logger message="#["UserID: " + sessionVars.userID + " | UserName: " + sessionVars.userName]" level="INFO" doc:name="Output the test"/>
</flow>
The output of the logger is:
processor.LoggerMessageProcessor: UserID: U001 | UserName: Dharmin