You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by juliaaano <ju...@gmail.com> on 2016/07/12 16:29:46 UTC
camel-sql IN query number of parameters mismatch
I'm running Camel 2.17.2.
I've been experiencing a problem when using IN query in a SQL statement
where there is more than one parameter, besides the one declared within the
IN clause. For example:
.to("SELECT * FROM projects WHERE license = :#${body} AND project IN
(:#in:names)")
Caused by: java.sql.SQLException: Number of parameters mismatch. Expected:
3, was: 2
at
org.apache.camel.component.sql.DefaultSqlPrepareStatementStrategy.populateStatement(DefaultSqlPrepareStatementStrategy.java:153)
at
org.apache.camel.component.sql.SqlProducer$2.doInPreparedStatement(SqlProducer.java:146)
at
org.apache.camel.component.sql.SqlProducer$2.doInPreparedStatement(SqlProducer.java:116)
at
org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:629)
... 54 more
I've noticed someone already mentioned this in another recent thread, but I
don't find this specific issue being considered there.
I forked Camel, created a test case that reproduces the problem and pushed
in a branch here:
https://github.com/juliaaano/camel/tree/sql-in-multiple-params
Do you guys consider this to be a bug? I'd be happy to report and submit a
pull request with the fix.
I suspect the problem is around
org.apache.camel.component.sql.DefaultSqlPrepareStatementStrategy.NamedQueryParser
in the next() method.
Please let me know how I can help. I'd love to contribute.
Thanks.
--
View this message in context: http://camel.465427.n5.nabble.com/camel-sql-IN-query-number-of-parameters-mismatch-tp5785054.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: R: Re: camel-sql IN query number of parameters mismatch(2.18.0)
Posted by imranrazakhan <im...@gmail.com>.
Hi Julian,
One observation regarding camel-sql(2.18.0) IN query , if we have one
dynamic IN it works fine but if we have two dynamic IN it throws error, if i
replace msisdn with static value it works fine, i tested with 2.18.0
select * from subscriber s
where status NOT IN(7,8)
AND s.msisdn IN( :#in:msisdns )
AND s.campaign_id IN( :#in:campId )
Stacktrace
---------------------------------------------------------------------------------------------------------------------------------------
org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback;
bad SQL grammar []; nested exception is java.sql.SQLSyntaxErrorException:
ORA-00942: table or view does not exist
at
org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:231)
at
org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:73)
at
org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:649)
at org.apache.camel.component.sql.SqlProducer.process(SqlProducer.java:116)
--
View this message in context: http://camel.465427.n5.nabble.com/camel-sql-IN-query-number-of-parameters-mismatch-tp5785054p5790241.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: R: Re: camel-sql IN query number of parameters mismatch
Posted by juliaaano <ju...@gmail.com>.
Thanks, Claus. I was about to start on doing that now. I you haven't gone too
far, I still volunteer to work on it. Cheers.
--
View this message in context: http://camel.465427.n5.nabble.com/camel-sql-IN-query-number-of-parameters-mismatch-tp5785054p5785175.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: R: Re: camel-sql IN query number of parameters mismatch
Posted by Claus Ibsen <cl...@gmail.com>.
Hi
I logged a ticket and are working on a fix
https://issues.apache.org/jira/browse/CAMEL-10151
On Fri, Jul 15, 2016 at 5:45 PM, Claus Ibsen <cl...@gmail.com> wrote:
> Hi
>
> Yeah that is a bug in the parser when you have dynamic body and IN
> together. You are welcome to log a JIRA and submit a PR with an unit
> test (create a new unit test so the existing test can be as-is)
>
> On Wed, Jul 13, 2016 at 7:11 PM, juliaaano <ju...@gmail.com> wrote:
>> Yes. Unfortunately I still have the same problem for an endpoint such as:
>>
>> .toD("sql:UPDATE orders SET customer = :#Customer WHERE orderId IN
>> (:#in:orders)")
>>
>> I don't see how this could have solved the problem since I have failing unit
>> tests at the sql component level. Should I make this tests available in a
>> different way other than by publishing through a branch like I have already
>> done?
>>
>> Thanks!
>>
>>
>>
>> --
>> View this message in context: http://camel.465427.n5.nabble.com/camel-sql-IN-query-number-of-parameters-mismatch-tp5785054p5785088.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>
>
> --
> Claus Ibsen
> -----------------
> http://davsclaus.com @davsclaus
> Camel in Action 2: https://www.manning.com/ibsen2
--
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2
Re: R: Re: camel-sql IN query number of parameters mismatch
Posted by Claus Ibsen <cl...@gmail.com>.
Hi
Yeah that is a bug in the parser when you have dynamic body and IN
together. You are welcome to log a JIRA and submit a PR with an unit
test (create a new unit test so the existing test can be as-is)
On Wed, Jul 13, 2016 at 7:11 PM, juliaaano <ju...@gmail.com> wrote:
> Yes. Unfortunately I still have the same problem for an endpoint such as:
>
> .toD("sql:UPDATE orders SET customer = :#Customer WHERE orderId IN
> (:#in:orders)")
>
> I don't see how this could have solved the problem since I have failing unit
> tests at the sql component level. Should I make this tests available in a
> different way other than by publishing through a branch like I have already
> done?
>
> Thanks!
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/camel-sql-IN-query-number-of-parameters-mismatch-tp5785054p5785088.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
--
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2
Re: R: Re: camel-sql IN query number of parameters mismatch
Posted by juliaaano <ju...@gmail.com>.
Yes. Unfortunately I still have the same problem for an endpoint such as:
.toD("sql:UPDATE orders SET customer = :#Customer WHERE orderId IN
(:#in:orders)")
I don't see how this could have solved the problem since I have failing unit
tests at the sql component level. Should I make this tests available in a
different way other than by publishing through a branch like I have already
done?
Thanks!
--
View this message in context: http://camel.465427.n5.nabble.com/camel-sql-IN-query-number-of-parameters-mismatch-tp5785054p5785088.html
Sent from the Camel - Users mailing list archive at Nabble.com.
R: Re: camel-sql IN query number of parameters mismatch
Posted by Andrea Cosentino <an...@yahoo.com.INVALID>.
Did you try with a dinamica endpoint toD?
Il mer, 13 lug, 2016 alle 12:13, juliaaano<ju...@gmail.com> ha scritto: Hello,
I don't think this is related to the driver. I've extended the existing
camel test case to reproduce the aforementioned scenario. Check it out at
https://github.com/juliaaano/camel/tree/sql-in-multiple-params
There is not Oracle JBDC driver involved in the unit test as well as with
the setup I run in production. I also experimented with the
"parametersCount" option and no success there.
I've already dig into the sql component implementation and probably found
the source of the problem in that class highlighted in my previous post.
Again, If you guys find this is a bug I'd be happy to report and fix it.
Thanks.
--
View this message in context: http://camel.465427.n5.nabble.com/camel-sql-IN-query-number-of-parameters-mismatch-tp5785054p5785067.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: camel-sql IN query number of parameters mismatch
Posted by juliaaano <ju...@gmail.com>.
Hello,
I don't think this is related to the driver. I've extended the existing
camel test case to reproduce the aforementioned scenario. Check it out at
https://github.com/juliaaano/camel/tree/sql-in-multiple-params
There is not Oracle JBDC driver involved in the unit test as well as with
the setup I run in production. I also experimented with the
"parametersCount" option and no success there.
I've already dig into the sql component implementation and probably found
the source of the problem in that class highlighted in my previous post.
Again, If you guys find this is a bug I'd be happy to report and fix it.
Thanks.
--
View this message in context: http://camel.465427.n5.nabble.com/camel-sql-IN-query-number-of-parameters-mismatch-tp5785054p5785067.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: camel-sql IN query number of parameters mismatch
Posted by Tadayoshi Sato <sa...@gmail.com>.
Hi,
Looks like the same issue was discussed in this ML a month ago :-)
http://camel.465427.n5.nabble.com/camel-sql-SQL-IN-Query-issue-2-17-1-td5783264.html
Isn't it the same as yours? For convenience, Claus suggested the following
solution in that thread:
> I wonder if its the Oracle JDBC driver issue, that it does not return
> correct value for number of parameters in the prepared statement.
>
> There is an option parametersCount you can use to set a fixed value if
> the JDBC driver cannot return correct data. See its documentation
> http://camel.apache.org/sql-component.html
>
> However that value is fixed, and if you use a dynamic IN list then you
> would need to use <toD> to make the uri dynamic. (less good but
> possible). But at least maybe try to set that value = 1000 as you use
> in your example, and see if that at least work.
On Wed, Jul 13, 2016 at 1:29 AM, juliaaano <ju...@gmail.com> wrote:
> I'm running Camel 2.17.2.
>
> I've been experiencing a problem when using IN query in a SQL statement
> where there is more than one parameter, besides the one declared within the
> IN clause. For example:
>
> .to("SELECT * FROM projects WHERE license = :#${body} AND project IN
> (:#in:names)")
>
> Caused by: java.sql.SQLException: Number of parameters mismatch. Expected:
> 3, was: 2
> at
>
> org.apache.camel.component.sql.DefaultSqlPrepareStatementStrategy.populateStatement(DefaultSqlPrepareStatementStrategy.java:153)
> at
>
> org.apache.camel.component.sql.SqlProducer$2.doInPreparedStatement(SqlProducer.java:146)
> at
>
> org.apache.camel.component.sql.SqlProducer$2.doInPreparedStatement(SqlProducer.java:116)
> at
> org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:629)
> ... 54 more
>
> I've noticed someone already mentioned this in another recent thread, but I
> don't find this specific issue being considered there.
>
> I forked Camel, created a test case that reproduces the problem and pushed
> in a branch here:
>
> https://github.com/juliaaano/camel/tree/sql-in-multiple-params
>
> Do you guys consider this to be a bug? I'd be happy to report and submit a
> pull request with the fix.
>
> I suspect the problem is around
>
> org.apache.camel.component.sql.DefaultSqlPrepareStatementStrategy.NamedQueryParser
> in the next() method.
>
> Please let me know how I can help. I'd love to contribute.
>
> Thanks.
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/camel-sql-IN-query-number-of-parameters-mismatch-tp5785054.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>