You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Licia <al...@gmail.com> on 2014/07/09 11:56:17 UTC

Configuring database with jdbc

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.

Re: Configuring database with jdbc

Posted by Charles Moulliard <ch...@gmail.com>.
Hi Licia,

Here is a project (part of the FuseByExample github repo) where there is an
example about how to setup the camel jdbc component using spring to
instantiate a DataSource.

https://github.com/FuseByExample/camel-persistence-part1/blob/master/jdbc/src/main/resources/META-INF/spring/camelContext.xml#L71

Regards,

Charles


On Wed, Jul 9, 2014 at 11:56 AM, Licia <al...@gmail.com> wrote:

> 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.
>



-- 
Charles Moulliard
Apache Committer / Architect @RedHat
Twitter : @cmoulliard | Blog :  http://cmoulliard.github.io

Re: Configuring database with jdbc

Posted by fradj zayen <za...@gmail.com>.
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 <al...@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.
>

Re: Configuring database with jdbc

Posted by Charles Moulliard <ch...@gmail.com>.
To use the Camel JDBC component and to establish a connection with your
Database, a DataSource object must be instantiated (
http://docs.oracle.com/javase/7/docs/api/javax/sql/DataSource.html). This
can be done using Java Code or with the help of Spring framework
instantiating the bean for you and register in a "container" of java beans
that Camel can use to find the beans/java objects.


On Wed, Jul 9, 2014 at 1:53 PM, Licia <al...@gmail.com> wrote:

> I don't really understand what you mean by "data source spring
> configuration".
>
> Maybe it's something I lack.
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Configuring-database-with-jdbc-tp5753574p5753583.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Charles Moulliard
Apache Committer / Architect @RedHat
Twitter : @cmoulliard | Blog :  http://cmoulliard.github.io

Re: Configuring database with jdbc

Posted by Licia <al...@gmail.com>.
It works well now, thank you, I don't think I would have been able to see it
myself. 

Just so that this post is not useless, I would (now) recommend the registry
method that was given, it helped me a lot. 

I also looked at another question that had been asked and that helped me :
http://camel.465427.n5.nabble.com/how-to-do-a-registry-of-type-javax-sql-DataSource-td5729644.html

Thank you anyway. 



--
View this message in context: http://camel.465427.n5.nabble.com/Configuring-database-with-jdbc-tp5753574p5753602.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Configuring database with jdbc

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Make sure you spell datasource the same. Dont you have

- datasource
- dataSource



On Wed, Jul 9, 2014 at 2:39 PM, Licia <al...@gmail.com> wrote:
> I tried what you said. I just removed the camel-context.xml and wrote this in
> my main :
>
> public static void main( String[] args ) throws Exception
>    {
>         //Configuring the database
>         DriverManagerDataSource ds= new DriverManagerDataSource();
>
>         ds.setDriverClassName("com.mysql.jdbc.Driver");
>         ds.setUrl("jdbc:mysql://172.27.178.73:3306");
>         ds.setUsername("dev");
>         ds.setPassword("sopragroup");
>
>         SimpleRegistry reg = new SimpleRegistry();
>         reg.put("datasource",ds);
>
>         //Creating the context
>         CamelContext  myContext = new DefaultCamelContext(reg);
>
>         //Configuring the route
>         XmlRoute myRoute = new XmlRoute();
>
>         myContext.addRoutes(myRoute);
>
>         //Launching the context
>         myContext.start();
>         //Pausing to let the route do its work
>         Thread.sleep(10000);
>         //Stopping the context
>         myContext.stop();
>
>     }
>
>
> But anyways, I'm still getting the exact same errors.
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Configuring-database-with-jdbc-tp5753574p5753598.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/

Re: Configuring database with jdbc

Posted by Licia <al...@gmail.com>.
I tried what you said. I just removed the camel-context.xml and wrote this in
my main : 

public static void main( String[] args ) throws Exception
   {
    	//Configuring the database
    	DriverManagerDataSource ds= new DriverManagerDataSource();
    	
    	ds.setDriverClassName("com.mysql.jdbc.Driver");
    	ds.setUrl("jdbc:mysql://172.27.178.73:3306");
    	ds.setUsername("dev");
    	ds.setPassword("sopragroup");
    	
    	SimpleRegistry reg = new SimpleRegistry();
    	reg.put("datasource",ds);
    	
    	//Creating the context
        CamelContext  myContext = new DefaultCamelContext(reg);
        
        //Configuring the route
        XmlRoute myRoute = new XmlRoute();
        
        myContext.addRoutes(myRoute);
        
        //Launching the context
        myContext.start();
        //Pausing to let the route do its work
        Thread.sleep(10000);
        //Stopping the context
        myContext.stop();       
        
    }


But anyways, I'm still getting the exact same errors. 



--
View this message in context: http://camel.465427.n5.nabble.com/Configuring-database-with-jdbc-tp5753574p5753598.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Configuring database with jdbc

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

You are mixing spring xml and starting Apache Camel from a java main
class. Basically you do not start Spring as well.

So either remove spring and register the datasource in SimpleRegistry
which you pass into the DefaultCamelContext constructor.

Or include spring on startup.

There is a Main class from Camel that can load spring also. See the
Main from camel-spring.

See this link
http://camel.apache.org/running-camel-standalone-and-have-it-keep-running.html

On Wed, Jul 9, 2014 at 2:05 PM, Licia <al...@gmail.com> wrote:
> Here is my* spring configuration *:
>
> <?xml version="1.0" encoding="UTF-8"?>
>
> <beans xmlns="http://www.springframework.org/schema/beans"
>        xmlns:jdbc="http://www.springframework.org/schema/jdbc"
>        xmlns:camel="http://camel.apache.org/schema/spring"
>        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>        xsi:schemaLocation="
>                 http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans.xsd
>                 http://www.springframework.org/schema/jdbc
> http://www.springframework.org/schema/jdbc/spring-jdbc.xsd
>                 http://camel.apache.org/schema/spring
> http://camel.apache.org/schema/spring/camel-spring.xsd">
>
>          <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
>                 destroy-method="close">
>                 <property name="url" value="jdbc:mysql://172.27.178.73:3306/db" />
>                 <property name="driverClassName" value="com.mysql.jdbc.Driver" />
>                 <property name="username" value="dev" />
>                 <property name="password" value="mypassword" />
>         </bean>
>
> </beans>
>
>
> Now, my *route*
>
> public class XmlRoute extends RouteBuilder
> {
>
>         public void configure() throws Exception
>         {
>                 //Transforming xml into database
>                 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");
>
>
>         }
> }
>
> Finally* my main* (maybe it's from there)
> public static void main( String[] args ) throws Exception
>    {
>
>         //Creating the context
>         CamelContext  myContext = new DefaultCamelContext();
>
>         //Configuring the route
>         XmlRoute myRoute = new XmlRoute();
>
>         myContext.addRoutes(myRoute);
>
>         //Launching the context
>         myContext.start();
>         //Pausing to let the route do its work
>         Thread.sleep(10000);
>         //Stopping the context
>         myContext.stop();
>
>     }
>
>
> The *exception* thrown are :
> Exception in thread "main" org.apache.camel.FailedToCreateRouteException:
> Failed to create route route1 at: >>> Split[xpath{XPath:
> /tabnames/tabname/subTrajectory/month} ->
> [Filter[xpath{/month[@name="janvier"]} -> [SetHeader[lic, xpath{XPath:
> /month/@nbWorkedDays}], SetHeader[min, xpath{XPath:
> /month/amount[@type="ca"]/month/text()}], SetBody[simple{Simple: select *
> from projects where license = ${header.lic} and id > ${header.min} order by
> id}], To[jdbc:dataSource?useHeadersAsParameters=true],
> To[log:toto?level=ERROR]]]]] <<< in route:
> Route(route1)[[From[file:src/data/xmlTest]] -> [Split[xpath{... because of
> Failed to resolve endpoint: jdbc://dataSource?useHeadersAsParameters=true
> due to: No bean could be found in the registry for: dataSource of type:
> javax.sql.DataSource
>         at
> org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:910)
>         at
> org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:175)
>         at
> org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:778)
>         at
> org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:2041)
>         at
> org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:1791)
>         at
> org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:1665)
>         at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
>         at
> org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:1633)
>         at com.sopra.camelProject.FileCopier.main(FileCopier.java:38)
> Caused by: org.apache.camel.ResolveEndpointFailedException: Failed to
> resolve endpoint: jdbc://dataSource?useHeadersAsParameters=true due to: No
> bean could be found in the registry for: dataSource of type:
> javax.sql.DataSource
>         at
> org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:532)
>         at
> org.apache.camel.util.CamelContextHelper.getMandatoryEndpoint(CamelContextHelper.java:71)
>         at
> org.apache.camel.model.RouteDefinition.resolveEndpoint(RouteDefinition.java:190)
>         at
> org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:106)
>         at
> org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:112)
>         at
> org.apache.camel.model.SendDefinition.resolveEndpoint(SendDefinition.java:61)
>         at
> org.apache.camel.model.SendDefinition.createProcessor(SendDefinition.java:55)
>         at
> org.apache.camel.model.ProcessorDefinition.createProcessor(ProcessorDefinition.java:459)
>         at
> org.apache.camel.model.ProcessorDefinition.createOutputsProcessor(ProcessorDefinition.java:428)
>         at
> org.apache.camel.model.ProcessorDefinition.createOutputsProcessor(ProcessorDefinition.java:158)
>         at
> org.apache.camel.model.ProcessorDefinition.createChildProcessor(ProcessorDefinition.java:177)
>         at
> org.apache.camel.model.FilterDefinition.createFilterProcessor(FilterDefinition.java:72)
>         at
> org.apache.camel.model.FilterDefinition.createProcessor(FilterDefinition.java:66)
>         at
> org.apache.camel.model.FilterDefinition.createProcessor(FilterDefinition.java:34)
>         at
> org.apache.camel.model.ProcessorDefinition.createProcessor(ProcessorDefinition.java:459)
>         at
> org.apache.camel.model.ProcessorDefinition.createOutputsProcessor(ProcessorDefinition.java:428)
>         at
> org.apache.camel.model.ProcessorDefinition.createOutputsProcessor(ProcessorDefinition.java:158)
>         at
> org.apache.camel.model.ProcessorDefinition.createChildProcessor(ProcessorDefinition.java:177)
>         at
> org.apache.camel.model.SplitDefinition.createProcessor(SplitDefinition.java:101)
>         at
> org.apache.camel.model.ProcessorDefinition.makeProcessor(ProcessorDefinition.java:499)
>         at
> org.apache.camel.model.ProcessorDefinition.addRoutes(ProcessorDefinition.java:212)
>         at
> org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:907)
>         ... 8 more
> Caused by: org.apache.camel.NoSuchBeanException: No bean could be found in
> the registry for: dataSource of type: javax.sql.DataSource
>         at
> org.apache.camel.util.CamelContextHelper.mandatoryLookup(CamelContextHelper.java:151)
>         at
> org.apache.camel.component.jdbc.JdbcComponent.createEndpoint(JdbcComponent.java:49)
>         at
> org.apache.camel.impl.DefaultComponent.createEndpoint(DefaultComponent.java:123)
>         at
> org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:512)
>         ... 29 more
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Configuring-database-with-jdbc-tp5753574p5753592.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/

Re: Configuring database with jdbc

Posted by Licia <al...@gmail.com>.
Here is my* spring configuration *:

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:jdbc="http://www.springframework.org/schema/jdbc"
       xmlns:camel="http://camel.apache.org/schema/spring"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="
		http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
		http://www.springframework.org/schema/jdbc
http://www.springframework.org/schema/jdbc/spring-jdbc.xsd
		http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd">
	
	 <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" 
		destroy-method="close"> 
		<property name="url" value="jdbc:mysql://172.27.178.73:3306/db" /> 
		<property name="driverClassName" value="com.mysql.jdbc.Driver" /> 
		<property name="username" value="dev" /> 
		<property name="password" value="mypassword" />
	</bean> 

</beans>


Now, my *route*

public class XmlRoute extends RouteBuilder
{
	
	public void configure() throws Exception
	{
		//Transforming xml into database
		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");
		    

	}
}

Finally* my main* (maybe it's from there)
public static void main( String[] args ) throws Exception
   {

    	//Creating the context
        CamelContext  myContext = new DefaultCamelContext();
        
        //Configuring the route
        XmlRoute myRoute = new XmlRoute();
        
        myContext.addRoutes(myRoute);
        
        //Launching the context
        myContext.start();
        //Pausing to let the route do its work
        Thread.sleep(10000);
        //Stopping the context
        myContext.stop();       
        
    }


The *exception* thrown are : 
Exception in thread "main" org.apache.camel.FailedToCreateRouteException:
Failed to create route route1 at: >>> Split[xpath{XPath:
/tabnames/tabname/subTrajectory/month} ->
[Filter[xpath{/month[@name="janvier"]} -> [SetHeader[lic, xpath{XPath:
/month/@nbWorkedDays}], SetHeader[min, xpath{XPath:
/month/amount[@type="ca"]/month/text()}], SetBody[simple{Simple: select *
from projects where license = ${header.lic} and id > ${header.min} order by
id}], To[jdbc:dataSource?useHeadersAsParameters=true],
To[log:toto?level=ERROR]]]]] <<< in route:
Route(route1)[[From[file:src/data/xmlTest]] -> [Split[xpath{... because of
Failed to resolve endpoint: jdbc://dataSource?useHeadersAsParameters=true
due to: No bean could be found in the registry for: dataSource of type:
javax.sql.DataSource
	at
org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:910)
	at
org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:175)
	at
org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:778)
	at
org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:2041)
	at
org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:1791)
	at
org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:1665)
	at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
	at
org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:1633)
	at com.sopra.camelProject.FileCopier.main(FileCopier.java:38)
Caused by: org.apache.camel.ResolveEndpointFailedException: Failed to
resolve endpoint: jdbc://dataSource?useHeadersAsParameters=true due to: No
bean could be found in the registry for: dataSource of type:
javax.sql.DataSource
	at
org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:532)
	at
org.apache.camel.util.CamelContextHelper.getMandatoryEndpoint(CamelContextHelper.java:71)
	at
org.apache.camel.model.RouteDefinition.resolveEndpoint(RouteDefinition.java:190)
	at
org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:106)
	at
org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:112)
	at
org.apache.camel.model.SendDefinition.resolveEndpoint(SendDefinition.java:61)
	at
org.apache.camel.model.SendDefinition.createProcessor(SendDefinition.java:55)
	at
org.apache.camel.model.ProcessorDefinition.createProcessor(ProcessorDefinition.java:459)
	at
org.apache.camel.model.ProcessorDefinition.createOutputsProcessor(ProcessorDefinition.java:428)
	at
org.apache.camel.model.ProcessorDefinition.createOutputsProcessor(ProcessorDefinition.java:158)
	at
org.apache.camel.model.ProcessorDefinition.createChildProcessor(ProcessorDefinition.java:177)
	at
org.apache.camel.model.FilterDefinition.createFilterProcessor(FilterDefinition.java:72)
	at
org.apache.camel.model.FilterDefinition.createProcessor(FilterDefinition.java:66)
	at
org.apache.camel.model.FilterDefinition.createProcessor(FilterDefinition.java:34)
	at
org.apache.camel.model.ProcessorDefinition.createProcessor(ProcessorDefinition.java:459)
	at
org.apache.camel.model.ProcessorDefinition.createOutputsProcessor(ProcessorDefinition.java:428)
	at
org.apache.camel.model.ProcessorDefinition.createOutputsProcessor(ProcessorDefinition.java:158)
	at
org.apache.camel.model.ProcessorDefinition.createChildProcessor(ProcessorDefinition.java:177)
	at
org.apache.camel.model.SplitDefinition.createProcessor(SplitDefinition.java:101)
	at
org.apache.camel.model.ProcessorDefinition.makeProcessor(ProcessorDefinition.java:499)
	at
org.apache.camel.model.ProcessorDefinition.addRoutes(ProcessorDefinition.java:212)
	at
org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:907)
	... 8 more
Caused by: org.apache.camel.NoSuchBeanException: No bean could be found in
the registry for: dataSource of type: javax.sql.DataSource
	at
org.apache.camel.util.CamelContextHelper.mandatoryLookup(CamelContextHelper.java:151)
	at
org.apache.camel.component.jdbc.JdbcComponent.createEndpoint(JdbcComponent.java:49)
	at
org.apache.camel.impl.DefaultComponent.createEndpoint(DefaultComponent.java:123)
	at
org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:512)
	... 29 more



--
View this message in context: http://camel.465427.n5.nabble.com/Configuring-database-with-jdbc-tp5753574p5753592.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Configuring database with jdbc

Posted by akoufoudakis <ak...@gmail.com>.
Can you, please, repost again what you have for now:
route (from...to), spring configuration, and the exception, which is thrown
now?



--
View this message in context: http://camel.465427.n5.nabble.com/Configuring-database-with-jdbc-tp5753574p5753589.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Configuring database with jdbc

Posted by Licia <al...@gmail.com>.
I think you saw the next error I was going to running to. 

But it didn't change the problem. I even tried to add in my pom.xml 

<dependency>
		<groupId>mysql</groupId>
		<artifactId>mysql-connector-java</artifactId>
		<version>5.1.9</version>
</dependency>

Just to see if it would make a difference. And it didn't. :/



--
View this message in context: http://camel.465427.n5.nabble.com/Configuring-database-with-jdbc-tp5753574p5753588.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Configuring database with jdbc

Posted by akoufoudakis <ak...@gmail.com>.
I think, there is a small problem.
In your route, you still call it "dataSource".
However, in your bean definition, you call it as "myDataSource".
Check, if it helps.



--
View this message in context: http://camel.465427.n5.nabble.com/Configuring-database-with-jdbc-tp5753574p5753587.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Configuring database with jdbc

Posted by Licia <al...@gmail.com>.
So I tried what you all said. (And now I get it about the
springConfiguration).

My spring configuration now looks like that : 

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:jdbc="http://www.springframework.org/schema/jdbc"
       xmlns:camel="http://camel.apache.org/schema/spring"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="
		http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
		http://www.springframework.org/schema/jdbc
http://www.springframework.org/schema/jdbc/spring-jdbc.xsd
		http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd">
	
	* <bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource" 
		destroy-method="close"> 
		<property name="url" value="jdbc:mysql://172.27.178.73:3306/db" /> 
		<property name="driverClassName" value="com.mysql.jdbc.Driver" /> 
		<property name="username" value="dev" /> 
		<property name="password" value="mypassword" />
	</bean> *

</beans>


But now I get an error I don't really understand called
:"NoSuchBeanException"



Exception in thread "main" org.apache.camel.FailedToCreateRouteException:
Failed to create route route1 at: >>> Split[xpath{XPath:
/tabnames/tabname/subTrajectory/month} -> [...]],
To[jdbc:dataSource?useHeadersAsParameters=true] <<< in route:
Route(route1)[[From[file:src/data/xmlTest]] -> [Split[xpath{... because of
Failed to resolve endpoint: jdbc://dataSource?useHeadersAsParameters=true
due to: No bean could be found in the registry for: dataSource of type:
javax.sql.DataSource
	[...]
Caused by: org.apache.camel.ResolveEndpointFailedException: Failed to
resolve endpoint: jdbc://dataSource?useHeadersAsParameters=true due to: No
bean could be found in the registry for: dataSource of type:
javax.sql.DataSource
	[...]
Caused by: org.apache.camel.NoSuchBeanException: No bean could be found in
the registry for: dataSource of type: javax.sql.DataSource
	[...]


Do I need something more than camel-core and camel-jdbc in my pom.xml ? 



--
View this message in context: http://camel.465427.n5.nabble.com/Configuring-database-with-jdbc-tp5753574p5753586.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Configuring database with jdbc

Posted by akoufoudakis <ak...@gmail.com>.
In your route:

 .to("jdbc:dataSource?useHeadersAsParameters=true");

the "dataSource" should be a data source (e. g., apache dbcp).
It should be configured via Spring as a bean.

<bean id = "dataSource" ...>
.....
</bean>.
To configure it properly, please check the link provided by Charles in his
reply to you or take fradj reply as an example.

If you have it already configured, check if there is a database connectivity
problem or check, whether your select statement is correct.



--
View this message in context: http://camel.465427.n5.nabble.com/Configuring-database-with-jdbc-tp5753574p5753585.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Configuring database with jdbc

Posted by Licia <al...@gmail.com>.
I don't really understand what you mean by "data source spring
configuration". 

Maybe it's something I lack.



--
View this message in context: http://camel.465427.n5.nabble.com/Configuring-database-with-jdbc-tp5753574p5753583.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Configuring database with jdbc

Posted by akoufoudakis <ak...@gmail.com>.
Hello, Licia!

Can you share, please, your data source spring configuration?



--
View this message in context: http://camel.465427.n5.nabble.com/Configuring-database-with-jdbc-tp5753574p5753576.html
Sent from the Camel - Users mailing list archive at Nabble.com.