Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9042477
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T10:30:08+00:00 2026-06-16T10:30:08+00:00

So I have a REST based service which is hosted at http://localhost:35798/RestServiceImpl.svc/json/567 If I

  • 0

So I have a REST based service which is hosted at

http://localhost:35798/RestServiceImpl.svc/json/567

If I query that, I get the result as:

{"JSONDataResult":"You requested product 567"}

I need to store the whole JSON data into a PostgreSQL table:

CREATE TABLE "JsonTable"
(
  "StoreJsonObject" json
)

If I want to parse the value field i.e. “You requested product 567”, the program works (here I am using a different table whose column type is text):

<jdbc:postgresql-data-source name="PostgreSQL_Data_Source" user="username" password="pwd" url="jdbc:postgresql://localhost:5432/TestDB" transactionIsolation="UNSPECIFIED" doc:name="PostgreSQL Data Source"/>
<jdbc:connector name="PostgreSQL_Connector" dataSource-ref="PostgreSQL_Data_Source" validateConnections="true" queryTimeout="-1" pollingFrequency="0" doc:name="Database">
    <jdbc:query key="InsertRecord" value="INSERT INTO &quot;AnotherJSonTable&quot;(&quot;StoreJsonObject&quot;) VALUES (#[message.payload])"/>
</jdbc:connector>
<flow name="testRestFlow1" doc:name="testRestFlow1">
    <http:inbound-endpoint exchange-pattern="request-response" address="http://localhost:8082/index.html"  doc:name="HTTP"/>
    <http:rest-service-component httpMethod="GET" serviceUrl="http://localhost:35798/RestServiceImpl.svc/json/567">
    </http:rest-service-component>
    <json:json-to-object-transformer returnClass="java.util.Map" doc:name="JSON to Object"/>
    <expression-transformer expression="#[message.payload.JSONDataResult]" doc:name="Expression"/>
    <jdbc:outbound-endpoint exchange-pattern="one-way" queryKey="InsertRecord" queryTimeout="-1" connector-ref="PostgreSQL_Connector" doc:name="Database"/>
</flow>

But how to store the entire JSON object ({“JSONDataResult”:”You requested product 567″}).
What do I need to change in the “expression-transformer”?

If I do:

<jdbc:query key="InsertRecord" value="INSERT INTO &quot;JsonTable&quot;(&quot;StoreJsonObject&quot;) VALUES (#[message.payload])"/>

<expression-transformer expression="#[message.payload]" doc:name="Expression"/>

I receive exception:

Root Exception stack trace:
org.postgresql.util.PSQLException: No hstore extension installed.
    at org.postgresql.jdbc2.AbstractJdbc2Statement.setMap(AbstractJdbc2Statement.java:1713)
    at org.postgresql.jdbc2.AbstractJdbc2Statement.setObject(AbstractJdbc2Statement.java:1916)
    at org.postgresql.jdbc3g.AbstractJdbc3gStatement.setObject(AbstractJdbc3gStatement.java:36)
    + 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************

INFO  2012-12-24 15:48:31,945 [[testrest].connector.file.mule.default.receiver.01] org.mule.transport.file.FileMessageReceiver: Lock obtained on file: C:\Users\niladri.biswas\Desktop\input\all_winjs_ui_controls.txt
INFO  2012-12-24 15:48:31,945 [[testrest].testRestFlow1.stage1.02] org.mule.transport.http.components.RestServiceWrapper: Invoking REST service: http://localhost:35798/RestServiceImpl.svc/json/567
ERROR 2012-12-24 15:48:31,992 [[testrest].PostgreSQL_Connector.dispatcher.01] org.mule.exception.DefaultMessagingExceptionStrategy: 
********************************************************************************
Message               : Failed to route event via endpoint: DefaultOutboundEndpoint{endpointUri=jdbc://InsertRecord, connector=JdbcConnector
{
  name=PostgreSQL_Connector
  lifecycle=start
  this=15e7ea6
  numberOfConcurrentTransactedReceivers=4
  createMultipleTransactedReceivers=false
  connected=true
  supportedProtocols=[jdbc]
  serviceOverrides=<none>
}
,  name='endpoint.jdbc.InsertRecord', mep=ONE_WAY, properties={queryTimeout=-1}, transactionConfig=Transaction{factory=null, action=INDIFFERENT, timeout=0}, deleteUnacceptedMessages=false, initialState=started, responseTimeout=10000, endpointEncoding=UTF-8, disableTransportTransformer=false}. Message payload is of type: LinkedHashMap
Code                  : MULE_ERROR--2
--------------------------------------------------------------------------------

Also the record should be inserted only once after reading from the service and not multiple times.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T10:30:09+00:00Added an answer on June 16, 2026 at 10:30 am

    Since you want to store the whole JSON, there is no need to deserialize it as an object: I suggest you simply transform the HTTP-streamed payload into a java.lang.String and insert it as-is in the DB.

    This would done like that:

    <jdbc:postgresql-data-source name="PostgreSQL_Data_Source"
        user="username" password="pwd" url="jdbc:postgresql://localhost:5432/TestDB"
        transactionIsolation="UNSPECIFIED" doc:name="PostgreSQL Data Source" />
    
    <jdbc:connector name="PostgreSQL_Connector" dataSource-ref="PostgreSQL_Data_Source"
        validateConnections="true" queryTimeout="-1" pollingFrequency="0"
        doc:name="Database">
        <jdbc:query key="InsertRecord"
            value="INSERT INTO &quot;AnotherJSonTable&quot;(&quot;StoreJsonObject&quot;) VALUES (CAST(#[message.payload] AS json))" />
    </jdbc:connector>
    
    <flow name="testRestFlow1" doc:name="testRestFlow1">
        <http:inbound-endpoint exchange-pattern="request-response"
            address="http://localhost:8082/index.html" doc:name="HTTP" />
        <http:rest-service-component httpMethod="GET"
            serviceUrl="http://localhost:35798/RestServiceImpl.svc/json/567" />
        <object-to-string-transformer />
        <jdbc:outbound-endpoint exchange-pattern="one-way"
            queryKey="InsertRecord" queryTimeout="-1" connector-ref="PostgreSQL_Connector"
            doc:name="Database" />
    </flow>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

am new to Json so a little green. I have a Rest Based Service
I have a REST service that returns a JSON like this: [{@id:123,name:Name}] and I'm
I have a WCF REST service that exposes a couple dozen objects and based
I have created a rest architecture based web service in C# which will return
I have a Jersey REST service which has endpoints that can return either application/xml
I have a REST service which takes a JSON request. I want to validate
I have a Spring MVC and Resteasy based REST service that i need to
I am trying to build a REST & json based WCF service that takes
I have a website that is mainly based on JavaScript. It uses a REST
I have a REST service for which I have a WADL file. I want

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.