You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Zemian Deng (JIRA)" <ji...@apache.org> on 2013/08/20 05:46:52 UTC

[jira] [Commented] (CAMEL-6091) Improvement to SqlProducer class

    [ https://issues.apache.org/jira/browse/CAMEL-6091?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13744667#comment-13744667 ] 

Zemian Deng commented on CAMEL-6091:
------------------------------------

BTW, I believe there is a workaround without using the patch also, but it's more involve like this:

{{sql:INSERT INTO [NEW_TABLE] SELECT * FROM [OLD_TABLE] WHERE ID = #?alwaysPopulateStatement=true&prepareStatementStrategy=#myStrategy}}

And then user can customize this {{myStrategy}} like this

{code}
strategy = new DefaultSqlPrepareStatementStrategy() {
            @Override
            public void populateStatement(PreparedStatement ps, Iterator<?> iterator, int expectedParams) throws SQLException {
                invoked = true;
                super.populateStatement(ps, iterator, expectedParams + 1);
            }
        };
{code}

Noticed the {{expectedParams + 1}} that should fixed user's use case.

But the patch would be more straightforward to use though.
                
> Improvement to SqlProducer class
> --------------------------------
>
>                 Key: CAMEL-6091
>                 URL: https://issues.apache.org/jira/browse/CAMEL-6091
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-sql
>    Affects Versions: 2.10.3
>            Reporter: Chris Miles
>            Priority: Minor
>             Fix For: Future
>
>         Attachments: CAMEL-6091.patch
>
>
> I have came across a bug with the Microsoft SQL Server driver (4.0) in where the folowing line is problematic:
> int expected = ps.getParameterMetaData().getParameterCount();
> If I run the following query through the component:
> INSERT INTO [NEW_TABLE] SELECT * FROM [OLD_TABLE] WHERE ID = #
> expected is set to 0 which results in my value not being set.
> Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: The value is not set for the parameter number 1.
> While this is a SQL Server issue, unfortunately the source is not available and an update is not likely any time soon to return the correct meta data. It would be handy if this Producer put the query preperation a little more into the hands of the user. I.e. let me say there are 5 parameters to be prepared along with the 5 values to use.
> If the user has manually put 5 items in a Map in the body, then can we not just use the map length to identify how many values and then iterate them.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira