You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by darwinanirudh <da...@gmail.com> on 2017/05/04 05:51:19 UTC

Unable to insert body data into table using sql component

Dear All, 


I need to insert the body values into table so i used sql component.

Since the data in the body should be of map data type , i tried the
following and i am getting the exception:

Caused by: org.apache.camel.FailedToCreateRouteException: Failed to create
route webproxyTest at: >>> ConvertBodyTo[java.util.map] <<< in route:
Route(webproxyTest)[[From[kafka:localhost:9092?topic=Mediate... because of
java.util.map

Caused by: java.lang.ClassNotFoundException: java.util.map




<from
uri="kafka:localhost:9092?topic=MediatedCdr&amp;zookeeperHost=localhost&amp;zookeeperPort=2181&amp;serializerClass=kafka.serializer.StringEncoder&amp;autoOffsetReset=smallest&amp;groupId=default"
/>
			
			<doTry>
			<to ref="callEventRestService" />
			<log message="after first display" />	
			<to uri="bean:Display?method=process" />
			<doCatch>
			
		
<exception>org.apache.camel.component.http.HttpOperationFailedException</exception>
			<log message="inside catch 2" />	
			
			<to uri="bean:Display?method=process" />
			
			
			</doCatch>
			
			</doTry>	
			
			<convertBodyTo type="java.util.map"/>
			
			<to uri="bean:Display?method=process" />

	<to uri="sql:{{sql.SusinsertQuery}}"/> 		
			
			<log message="after second display" />	
			
			<log message="aftersecond route" />	
		</route>

Sql query:

sql.SusinsertQuery=insert into error_details values (:#aNum,:#aNum,:#aNum)


Body data is in the form bye.

regards
Darwin













--
View this message in context: http://camel.465427.n5.nabble.com/Unable-to-insert-body-data-into-table-using-sql-component-tp5798623.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Unable to insert body data into table using sql component

Posted by darwinanirudh <da...@gmail.com>.
Thank you Claus Ibsen .

 I will add processor class to do conversion and set the returning map as
body.


 



--
View this message in context: http://camel.465427.n5.nabble.com/Unable-to-insert-body-data-into-table-using-sql-component-tp5798623p5798664.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Unable to insert body data into table using sql component

Posted by Claus Ibsen <cl...@gmail.com>.
Yes you need to build your own conversion from byte[] to Map to store
the data as you need it.

there is no possible way for camel or java to convert a byte array
into a map structure.

See this EIP
http://camel.apache.org/message-translator.html

On Thu, May 4, 2017 at 9:44 AM, darwinanirudh <da...@gmail.com> wrote:
> I tried
>
> <camel:convertBodyTo type="java.util.Map" />
>
>
> but i am getting the following error :
>
>  Caused by: No type converter available to convert from type: byte[] to the
> required type: java.util.Map with value [B@1190966. Exchange[Message:
> {"callDate":"2017-12-08","callDuration":"400","callTime":"17:50:15","aNum":"1241972582","bNum":"004152234","callType":"20","direction":"O","eventTransDet":[]}].
> Caused by: [org.apache.camel.NoTypeConversionAvailableException - No type
> converter available to convert from type: byte[] to the required type:
> java.util.Map with value [B@1190966]
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Unable-to-insert-body-data-into-table-using-sql-component-tp5798623p5798646.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2

Re: Unable to insert body data into table using sql component

Posted by darwinanirudh <da...@gmail.com>.
I tried 

<camel:convertBodyTo type="java.util.Map" />


but i am getting the following error :

 Caused by: No type converter available to convert from type: byte[] to the
required type: java.util.Map with value [B@1190966. Exchange[Message:
{"callDate":"2017-12-08","callDuration":"400","callTime":"17:50:15","aNum":"1241972582","bNum":"004152234","callType":"20","direction":"O","eventTransDet":[]}].
Caused by: [org.apache.camel.NoTypeConversionAvailableException - No type
converter available to convert from type: byte[] to the required type:
java.util.Map with value [B@1190966]




--
View this message in context: http://camel.465427.n5.nabble.com/Unable-to-insert-body-data-into-table-using-sql-component-tp5798623p5798646.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Unable to insert body data into table using sql component

Posted by darwinanirudh <da...@gmail.com>.
Sorry my mistake , it was M only ...

Yes i tried , but it says there is no type conversion from Byte[] to Map.

regards
Darwin



--
View this message in context: http://camel.465427.n5.nabble.com/Unable-to-insert-body-data-into-table-using-sql-component-tp5798623p5798647.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Unable to insert body data into table using sql component

Posted by Claus Ibsen <cl...@gmail.com>.
The Map must be using a big M letter.

On Thu, May 4, 2017 at 9:21 AM, darwinanirudh <da...@gmail.com> wrote:
> Thanks a lot for the reply.
>
> i have already used     <convertBodyTo type="java.util.map"/> before the sql
> clause .
>
> Or am i wrong ? Can you please elaborate .
>
> regards
> Darwin
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Unable-to-insert-body-data-into-table-using-sql-component-tp5798623p5798637.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2

Re: Unable to insert body data into table using sql component

Posted by darwinanirudh <da...@gmail.com>.
Thanks a lot for the reply.

i have already used     <convertBodyTo type="java.util.map"/> before the sql
clause .

Or am i wrong ? Can you please elaborate .

regards
Darwin
                         



--
View this message in context: http://camel.465427.n5.nabble.com/Unable-to-insert-body-data-into-table-using-sql-component-tp5798623p5798637.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Unable to insert body data into table using sql component

Posted by Claus Ibsen <cl...@gmail.com>.
Try with java.util.Map.


On Thu, May 4, 2017 at 1:51 AM, darwinanirudh <da...@gmail.com> wrote:
> Dear All,
>
>
> I need to insert the body values into table so i used sql component.
>
> Since the data in the body should be of map data type , i tried the
> following and i am getting the exception:
>
> Caused by: org.apache.camel.FailedToCreateRouteException: Failed to create
> route webproxyTest at: >>> ConvertBodyTo[java.util.map] <<< in route:
> Route(webproxyTest)[[From[kafka:localhost:9092?topic=Mediate... because of
> java.util.map
>
> Caused by: java.lang.ClassNotFoundException: java.util.map
>
>
>
>
> <from
> uri="kafka:localhost:9092?topic=MediatedCdr&amp;zookeeperHost=localhost&amp;zookeeperPort=2181&amp;serializerClass=kafka.serializer.StringEncoder&amp;autoOffsetReset=smallest&amp;groupId=default"
> />
>
>                         <doTry>
>                         <to ref="callEventRestService" />
>                         <log message="after first display" />
>                         <to uri="bean:Display?method=process" />
>                         <doCatch>
>
>
> <exception>org.apache.camel.component.http.HttpOperationFailedException</exception>
>                         <log message="inside catch 2" />
>
>                         <to uri="bean:Display?method=process" />
>
>
>                         </doCatch>
>
>                         </doTry>
>
>                         <convertBodyTo type="java.util.map"/>
>
>                         <to uri="bean:Display?method=process" />
>
>         <to uri="sql:{{sql.SusinsertQuery}}"/>
>
>                         <log message="after second display" />
>
>                         <log message="aftersecond route" />
>                 </route>
>
> Sql query:
>
> sql.SusinsertQuery=insert into error_details values (:#aNum,:#aNum,:#aNum)
>
>
> Body data is in the form bye.
>
> regards
> Darwin
>
>
>
>
>
>
>
>
>
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Unable-to-insert-body-data-into-table-using-sql-component-tp5798623.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2