[CONF] Apache Camel: SQL Component (page edited)

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

[CONF] Apache Camel: SQL Component (page edited)

Dhiraj Bokde (Confluence)

SQL Component has been edited by Claus Ibsen (Jun 01, 2008).

(View changes)


SQL Component

The sql: component allows you to work with databases using JDBC queries. The difference between this component and JDBC component is that in case of SQL the query is a property of the endpoint and it uses message payload as parameters passed to the query.

URI format

So far endpoints from this component could be used only as producers. It means that you cannot use them in from() statement.

SQL component uses following endpoint URI notation

sql:select * from table where id=# order by name?template.maxRows=10

Notice that standard ? symbol that denotes parameters to SQL query is substituted with # symbol as ? symbol is used to specify options for the endpoint.

Rules of treating message body

This component tries to convert the message body to Iterator and then, using this iterator it fills parameters of query.

It means that if the body is not an array, collection of iterator, then this conversion will result in iterator that iterates over only one object that is the body itself.

Results of invocation

Result of the invocation is effectively List<Map<String, Object>> as returned from JdbcTemplate.queryForList() method.


All options that are available are prefixed by template. and are properties of JdbcTemplate class. For detailed documentation see JdbcTemplate javadoc documentation.

Header values

When doing update operations the SQL Component stores the update count in the body header

header description
SqlProducer.UPDATE_COUNT The number of rows updated for update operations, returned as an Integer object.

See Also