camel-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From JonasF <jo...@fugedi.se>
Subject camel-sql ignoring parameters in header if no body
Date Fri, 15 Mar 2013 21:32:39 GMT
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.
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message