Hello,
Id'like to use a dynamic datasource with the camel-sql component but it's
not woking as I expected:
After a search on the forum, I have found a topic "Dynamic DataSource for
SQL", I try to do something similar :
from("direct:create")
.setHeader("dataSource", constant("myDynamicDataSource"))
.setHeader(SqlConstants.SQL_QUERY, simple("insert into customer(firstname,
lastname) values(:?firstName, :?lastName)"))
.setHeader("destination", new
QueryBuilder()).recipientList(header("destination"));
class QueryBuilder implements Expression {
@Override
public <T> T evaluate(Exchange exchange, Class<T> type) {
StringBuilder query = new StringBuilder();
query.append("sql:");
query.append(exchange.getIn().getHeader(SqlConstants.SQL_QUERY));
query.append("?dataSource=#");
query.append(exchange.getIn().getHeader("dataSource"));
return exchange.getContext().getTypeConverter().convertTo(type,
query.toString());
}
}
But I have this error message :
Failed to resolve endpoint:
sql://insert%20into%20customer(firstname,%20lastname)%20values(:?firstName%2C+%3A%3FlastName%29%3FdataSource=%23myDynamicDataSource
due to: DataSource must be configured
Any idea of the problem or another solution to implement a dynamic
datasource?
Thanks,
Arnaud
--
View this message in context:
http://camel.465427.n5.nabble.com/Dynamic-DataSource-tp5771402.html
Sent from the Camel - Users mailing list archive at Nabble.com.