How to run sql query using apache camel sqlComponent
<p>Hi I am new to apache camel framework (so most probobly the code I wrote is really bad :) ). I want to connect to my local database and run the sql query and then show up the results in consol. So far I have this:</p>

<pre><code>import javax.sql.DataSource;
import org.apache.camel.CamelContext;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.impl.DefaultCamelContext;
import org.apache.camel.impl.SimpleRegistry;
import org.apache.commons.dbcp2.BasicDataSource;

public class sqlENEIA3 {

public static void main(String[] args) throws Exception {
            String url = "jdbc:oracle:thin:@localhost:1521:ENETEST";
            DataSource dataSource = setupDataSource(url);

            SimpleRegistry reg = new SimpleRegistry();
            reg.put("myDataSource",dataSource);
            CamelContext context = new DefaultCamelContext(reg);    
            context.addRoutes(new sqlENEIA3().new MyRouteBuilder());


            context.start();
            Thread.sleep(5000);
            context.stop();

        }


          class MyRouteBuilder extends RouteBuilder {


            public void configure() {
            from("timer://Timer?period=60000").to("sql:select * from projects").to("stream:out");


            }
          } 

        private static DataSource setupDataSource(String connectURI) {
            BasicDataSource ds = new BasicDataSource();
            ds.setDriverClassName("org.apache.commons.dbcp.BasicDataSource"); 
            ds.setUsername("System");
            ds.setPassword("Igor_1");
            ds.setUrl(connectURI);
            return ds;
    }
  }
</code></pre>

<p>The error message I get is this:</p>

<pre><code>250 [main] INFO org.apache.camel.impl.DefaultCamelContext - Apache Camel     2.16.3 (CamelContext: camel-1) is starting
260 [main] INFO org.apache.camel.management.ManagedManagementStrategy - JMX is enabled
492 [main] INFO org.apache.camel.impl.converter.DefaultTypeConverter -        Loaded 186 type converters
542 [main] INFO org.apache.camel.impl.DefaultRuntimeEndpointRegistry -   Runtime endpoint registry is in extended mode gathering usage statistics of all   incoming and outgoing endpoints (cache limit: 1000)
632 [main] INFO org.apache.camel.impl.DefaultCamelContext - Apache Camel   2.16.3 (CamelContext: camel-1) is shutting down
642 [main] INFO org.apache.camel.impl.DefaultCamelContext - Apache Camel 2.16.3 (CamelContext: camel-1) uptime 0.382 seconds
642 [main] INFO org.apache.camel.impl.DefaultCamelContext - Apache Camel 2.16.3 (CamelContext: camel-1) is shutdown in 0.000 seconds
Exception in thread "main" org.apache.camel.FailedToCreateRouteException:   Failed to create route route1 at: &gt;&gt;&gt; To[sql:select * from projects] &lt;&lt;&lt; in   route: Route(route1)[[From[timer://Timer?period=60000]] -&gt; [To[sql:... because   of Failed to resolve endpoint: sql://select%20*%20from%20projects due to:   DataSource must be configured
at   org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:1072)
    at   org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:196)
    at org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:944)
    at org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:3260)
    at org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:2983)
    at org.apache.camel.impl.DefaultCamelContext.access$000(DefaultCamelContext.java:175)
    at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:2814)
    at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:2810)
    at org.apache.camel.impl.DefaultCamelContext.doWithDefinedClassLoader(DefaultCamelContext.java:2833)
    at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:2810)
    at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
    at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:2779)
    at com.ericsson.custom.opl.sqlENEIA3.main(sqlENEIA3.java:30)
    Caused by: org.apache.camel.ResolveEndpointFailedException: Failed to    resolve endpoint: sql://select%20*%20from%20projects due to: DataSource must be    configured
    at  org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:587)
    at org.apache.camel.util.CamelContextHelper.getMandatoryEndpoint(CamelContextHelper.java:79)
    at org.apache.camel.model.RouteDefinition.resolveEndpoint(RouteDefinition.java:211)
    at org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:107)
    at org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:113)
    at org.apache.camel.model.SendDefinition.resolveEndpoint(SendDefinition.java:62)
    at org.apache.camel.model.SendDefinition.createProcessor(SendDefinition.java:56)
    at org.apache.camel.model.ProcessorDefinition.makeProcessorImpl(ProcessorDefinition.java:535)
    at    org.apache.camel.model.ProcessorDefinition.makeProcessor(ProcessorDefinition.java:496)
    at org.apache.camel.model.ProcessorDefinition.addRoutes(ProcessorDefinition.java:220)
    at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:1069)
    ... 12 more
Caused by: java.lang.IllegalArgumentException: DataSource must be configured
    at org.apache.camel.component.sql.SqlComponent.createEndpoint(SqlComponent.java:74)
    at org.apache.camel.impl.DefaultComponent.createEndpoint(DefaultComponent.java:114)
    at  org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:5 67)
    ... 22 more
</code></pre>

<p>I assume that the problem is in my route, but every solution I found give the same result. Any help or advice will be helpful.</p>