Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: CAMEL-656 and CAMEL-1063

...

In the sample below we execute a query and retrieve the result as a List of rows where each rows is a Map<String, Object where the key is the column name. TODO: sample

First we setup a table to use for our sample. As this is based on an unit test we do it java code:

Wiki Markup
{snippet:id=e2|lang=java|url=activemq/camel/trunk/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlDataSourceRefTest.java}

Then we configure our route and our sql component. Notice that we use a direct endpoint in front of the sql. This allows us to send an exchange to the direct endpoint with the uri direct:simple that is much easier for client to use than the long URI that the sql component uses. Notice that the dataSource is lookup up in the registry. So we can use standard Spring XML to configure our DataSource.

Wiki Markup
{snippet:id=e1|lang=java|url=activemq/camel/trunk/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlDataSourceRefTest.java}

And then we fire the message into the direct endpoint that will route it to our sql component that queries the database.

Wiki Markup
{snippet:id=e3|lang=java|url=activemq/camel/trunk/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlDataSourceRefTest.java}

And we could configure the dataSource in Spring XML such as:

Code Block
xml
xml

 <jee:jndi-lookup id="myDS" jndi-name="jdbc/myDataSource"/> 
Include Page
CAMEL:Endpoint See Also
CAMEL:Endpoint See Also