You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by JonasF <jo...@fugedi.se> on 2013/03/15 22:32:39 UTC

camel-sql ignoring parameters in header if no body

When sending in a request over camel-jetty I added some parameters to the GET
request and passed it on to an SQL statement to enrich the response. As the
http request does not have body, only header fields, the SQL component
ignored my parameters and failed.I added some code to the SqlProducer which
resolved this issue:
if (exchange.getIn().getBody() != null) {                    if (batch) {                       
Iterator<?> iterator = exchange.getIn().getBody(Iterator.class);                       
while (iterator != null && iterator.hasNext()) {                           
Object value = iterator.next();                            Iterator<?> i =
getEndpoint().getPrepareStatementStrategy().createPopulateIterator(sql,
preparedQuery, expected, exchange, value);                           
getEndpoint().getPrepareStatementStrategy().populateStatement(ps, i,
expected);                            ps.addBatch();                       
}                    } else {                        Iterator<?> i =
getEndpoint().getPrepareStatementStrategy().createPopulateIterator(sql,
preparedQuery, expected, exchange, exchange.getIn().getBody());                       
getEndpoint().getPrepareStatementStrategy().populateStatement(ps, i,
expected);                    }                } else {                   
Iterator<?> i =
getEndpoint().getPrepareStatementStrategy().createPopulateIterator(sql,
preparedQuery, expected, exchange, null);                   
getEndpoint().getPrepareStatementStrategy().populateStatement(ps, i,
expected);                }
This worked fine for some where clause parameters, but not for a MySQL
'limit' parameter which became quoted and would therefor become rejected.So,
should this little fix be added to the camel-sql? And should the limit
parameter somehow be unquoted?Regards,Jonas Fügedi



--
View this message in context: http://camel.465427.n5.nabble.com/camel-sql-ignoring-parameters-in-header-if-no-body-tp5729269.html
Sent from the Camel Development mailing list archive at Nabble.com.