You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by dunnlow <du...@yahoo.com> on 2012/07/10 16:07:40 UTC
Using Camel with JDBCTemplate for Clob
Hi, I am using Camel 2.9 and Spring 3.1
I have been using the jdbc component to perform (transacted) inserts into my
database. It has been working well. However, there is a new test object in
the message that needs to be inserted into a Clob.
There isn't much information about using camel to insert Clobs. I found
this thread which suggests using a DAO and Spring JdbcTemplate.
(http://camel.465427.n5.nabble.com/Insert-into-CLOB-Column-in-Oracle-using-JDBC-Component-td4667458.html#a4673824)
There is plenty of information about using a JdbcTemplate to insert a Clob,
but I am unclear how to integrate this into my camel route.
Currently, I have a routes that load a pojo (from an xml file and from JMS).
The file route looks like:
<camel:route>
<camel:from uri="file:/events/"/>
<camel:bean ref="myEventBean" method="fromXML"/> <-- load the bean and
headers from XML
<camel:bean ref="myEventBean" method="toJDBC"/> <-- converts bean
attributes to jdbc
<camel:to uri="jdbc:myDatabase"/>
</camel:route>
<camel:route>
<camel:from uri="activemq:queue:events"/>
<camel:transacted/>
<camel:bean ref="myEventBean" method="fromHeaders"/> <-- load the bean
and headers
<camel:bean ref="myEventBean" method="toJDBC"/> <-- converts bean
attributes to jdbc
<camel:to uri="jdbc:myDatabase"/>
</camel:route>
It seems like I need to:
- Define a JDBCTemplate in my (application context).xml file,
- Change the toJDBC method (or create a new one) that uses that new template
to insert the Clob
- Get rid of the jdbc endpoint.
Does this seem correct? Is there a better way to work with Clobs? Also,
note the activemq route is transacted. Does implementing the JdbcTemplate
in my pojo break the transaction?
JdbcTemplate examples I found:
http://static.springsource.org/spring/docs/2.5.x/reference/jdbc.html
http://www.java2s.com/Code/Java/Spring/InsertClobData.htm
Thanks for any insight,
-J
--
View this message in context: http://camel.465427.n5.nabble.com/Using-Camel-with-JDBCTemplate-for-Clob-tp5715810.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Using Camel with JDBCTemplate for Clob
Posted by Christian Müller <ch...@gmail.com>.
-J,
as you may know Camel starts supporting Spring 3.1 starting with version
2.10.0...
In [1] you can find some information how to use the Spring JDBCTemplate.
In [2] and [3] you can find an example how to use a Spring Stored Procedure
in a Camel route. Hope this helps...
[1] http://static.springsource.org/spring/docs/3.0.x/reference/jdbc.html
[2]
https://github.com/muellerc/camel-in-daily-use/blob/master/part-2/src/main/java/org/apache/cmueller/camel/sus/cidu/part2/Route8.java
[3]
https://github.com/muellerc/camel-in-daily-use/blob/master/part-2/src/main/java/org/apache/cmueller/camel/sus/cidu/part2/JdbcBindingBean.java
Best,
Christian
On Tue, Jul 10, 2012 at 4:07 PM, dunnlow <du...@yahoo.com> wrote:
> Hi, I am using Camel 2.9 and Spring 3.1
>
> I have been using the jdbc component to perform (transacted) inserts into
> my
> database. It has been working well. However, there is a new test object
> in
> the message that needs to be inserted into a Clob.
>
> There isn't much information about using camel to insert Clobs. I found
> this thread which suggests using a DAO and Spring JdbcTemplate.
> (
> http://camel.465427.n5.nabble.com/Insert-into-CLOB-Column-in-Oracle-using-JDBC-Component-td4667458.html#a4673824
> )
>
> There is plenty of information about using a JdbcTemplate to insert a Clob,
> but I am unclear how to integrate this into my camel route.
>
> Currently, I have a routes that load a pojo (from an xml file and from
> JMS).
> The file route looks like:
>
> <camel:route>
> <camel:from uri="file:/events/"/>
> <camel:bean ref="myEventBean" method="fromXML"/> <-- load the bean and
> headers from XML
> <camel:bean ref="myEventBean" method="toJDBC"/> <-- converts bean
> attributes to jdbc
> <camel:to uri="jdbc:myDatabase"/>
> </camel:route>
>
> <camel:route>
> <camel:from uri="activemq:queue:events"/>
> <camel:transacted/>
> <camel:bean ref="myEventBean" method="fromHeaders"/> <-- load the bean
> and headers
> <camel:bean ref="myEventBean" method="toJDBC"/> <-- converts bean
> attributes to jdbc
> <camel:to uri="jdbc:myDatabase"/>
> </camel:route>
>
> It seems like I need to:
> - Define a JDBCTemplate in my (application context).xml file,
> - Change the toJDBC method (or create a new one) that uses that new
> template
> to insert the Clob
> - Get rid of the jdbc endpoint.
>
> Does this seem correct? Is there a better way to work with Clobs? Also,
> note the activemq route is transacted. Does implementing the JdbcTemplate
> in my pojo break the transaction?
>
> JdbcTemplate examples I found:
> http://static.springsource.org/spring/docs/2.5.x/reference/jdbc.html
> http://www.java2s.com/Code/Java/Spring/InsertClobData.htm
>
> Thanks for any insight,
> -J
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Using-Camel-with-JDBCTemplate-for-Clob-tp5715810.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>