camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fradj zayen <zaye...@gmail.com>
Subject Re: Configuring database with jdbc
Date Wed, 09 Jul 2014 10:08:41 GMT
Hi Licia,
you can use commons dbcp  for exampple to configurethe datasource. in your
spring configuration file you can add a bean as below
here is an example using MySQL
<bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="url" value="jdbc:mysql://localhost:3306/db" />
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="username" value="username" />
<property name="password" value="pwd" /></bean>
</beans>

the jdbc endpoint shoud refer to the bean id using datasource parameter

<to uri="sql:SELECT * FROM employees;?dataSource=#myDataSource"/>
hope it helps



2014-07-09 10:56 GMT+01:00 Licia <alicia.parisse@gmail.com>:

> Hi everyone,
>
> I'm currently still new at camel and I'm encoutering a problem.
>
> In fact, I have to use jdbc to make some Select/Insert SQL requests on my
> database.
> Until here, everything good.
>
> But when I use the configure method, I have a "Failed to resolve endpoint"
> error.
>
> Here is the configure method code :
> from ("file:src/data/xmlTest")
>         .split(xpath("/tabnames/tabname/subTrajectory/month"))
>         .filter().xpath("/month[@name=\"janvier\"]")
>         .setHeader("lic", xpath("/month/@nbWorkedDays"))
>         .setHeader("min",
> xpath("/month/amount[@type=\"ca\"]/month/text()"))
>         .setBody(simple("select * from projects where license =
> ${header.lic} and id > ${header.min} order by id"))
>         *.to("jdbc:dataSource?useHeadersAsParameters=true");*
>
> You'll see I'm already using xpath and things because I take inputs from an
> xml file. Everything works just fine as I expect before jdbc (I tried it
> using log at first). Anyway, the line that is really problematic for me is
> the bold one.
>
> I really don't know how to configure the database, saying how to connect to
> it (IP address etc.). I saw many exemples with camel-context.xml files but
> I
> don't know how to right it, cause every example I encountered was using a
> SQL script, first creating a database/table. But I don't want to do that
> since I already got one.
>
> If you know exemples or can explain, where/how to configure the database
> connection, I'd be very thankfull.
>
>
> P.S. : I already read the jdbc and sql examples from camel and it didn't
> really help me.
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Configuring-database-with-jdbc-tp5753574.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message