camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Grzegorz Grzybek <gr.grzy...@gmail.com>
Subject Re: Usage of properties in datasource definition - Please help
Date Sat, 20 Feb 2016 06:53:46 GMT
HI Launcelot

I see you're using Spring XML. Camel's <propertyPlaceholder> element
is used to resolve placeholders in Camel elements (like URIs).
However, in order to have your ${db.pass} replaced, you have to enable
Spring's own property placeholder. See here:
http://docs.spring.io/spring/docs/current/spring-framework-reference/htmlsingle/#xsd-config-body-schemas-context-pphc

Just add <context:property-placeholder> in your XML.

regards
Grzegorz

2016-02-19 23:38 GMT+01:00 Launcelot <drajagop@standard.com>:
> I have a property file defined as follows
> <camelContext trace="true"
>                 id="context-c2d439e2-f530-4c6d-8480-86f290cbf297"
> xmlns="http://camel.apache.org/schema/spring">
>
>                 <propertyPlaceholder id="properties" location="db.properties"
> propertyPrefix="${" propertySuffix="}"/>
>                 <route>
> db.properties has a property in it which contains
> db.pass=valuesnipped
>
>
> I have a datasource definition as under
> <bean id="myDataSource" class="org.apache.tomcat.jdbc.pool.DataSource">
>                 <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"
> />
>                 <property name="url" value="jdbc:oracle:thin:@seq1:1521:sfgd" />
>                 <property name="username" value="valuesnipped" />
>                 <property name="password" value="${db.pass}" />
>                 <property name="maxWait" value="1000" />
>                 <property name="validationQueryTimeout" value="3" />
>                 <property name="initialSize" value="8" />
>                 <property name="maxIdle" value="32" />
>                 <property name="removeAbandoned" value="true" />
>                 <property name="removeAbandonedTimeout" value="60" />
>                 <property name="logValidationErrors" value="true" />
>                 <property name="testWhileIdle" value="true" />
>                 <property name="testOnBorrow" value="true" />
>                 <property name="testOnConnect" value="true" />
>                 <property name="testOnReturn" value="false" />
>                 <property name="validationQuery" value="/* Oracle Health Check */
SELECT 1
> FROM DUAL" />
>
>         </bean>
>
> I get exceptions connecting to the database indicating invalid
> user/password. I have tried using {{db.pass}} which also does not work,
> probably because it is literally assigning the value as {{db.pass}}. If i
> just use the actual password above it works fine. The aim is ultimately to
> use jasypt but that is a problem for another day.
>
> Any help indicating how I can accomplish setting the password from a
> property file is appreciated.
>
> Thanks
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Usage-of-properties-in-datasource-definition-Please-help-tp5777954.html
> Sent from the Camel - Users mailing list archive at Nabble.com.

Mime
View raw message