camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: SQL Query Properties file
Date Fri, 06 Aug 2010 06:01:23 GMT
Hi

The Camel route can be done in pure XML with Spring
http://camel.apache.org/spring.html

The loading of the properties for the SQL can be done using the Camel
Properties component (requires Camel 2.3 or better)
http://camel.apache.org/properties.html



On Thu, Aug 5, 2010 at 4:07 PM, somemightsay <euanbegley@hotmail.com> wrote:
>
> Hi,
>
> I currently have a program which pulls data from a database and outputs it
> so a csv file.
>
> The SQL Query used is pulled in from a properties file but I would like to
> be able to define this in a bean within the Camel-Context.xml rather than
> using pure Java in the java class.
>
> Currently I have (Couldn't see a code tag, apologies if there is one):
>
> public void configure() throws Exception {
>                String query;
>          Properties props = new Properties();
>                     try {
>                     props.load(new FileInputStream("query.properties"));
>                     query = props.getProperty("query");
>
>                 CsvDataFormat csv = new CsvDataFormat();
>
>                 from("Schedule")
>                 .startupOrder(1)
>                 .setBody(constant(query))
>                 .to("jdbc:exampledb")
>                 .marshal(csv)
>                 .to("TargetDir");
>                      }
>
>
> but is there a way to do this similar to what I am using to pull in the
> database details from a properties file so that no addition code is needed
> in the java class? ie.
>
> <bean id="exampledb"
>
> class="org.springframework.jdbc.datasource.DriverManagerDataSource">
>                <property name="driverClassName" value="${driverClassName}"
> />
>                <property name="url" value="${url}" />
>                <property name="username" value="${username}" />
>                <property name="password" value="${password}" />
>        </bean>
>
> I have looked extensively on the camel website and google but could not find
> an exact answer. I am using Camel 2.2.
>
> Thanks.
> --
> View this message in context: http://camel.465427.n5.nabble.com/SQL-Query-Properties-file-tp2265391p2265391.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Mime
View raw message