user1912657
user1912657

Reputation: 189

Mule parameters in SQL queries

I'm trying to query two databases f102 which is MySQL and f100 which is SQL Server.

The query to the MySQL server works but the SQL Server connector doesn't like the "#[header:INBOUND:company] as company" and throws:

Root Exception stack trace:
java.sql.SQLException: Too many parameters: expected 0, was given 1
at org.apache.commons.dbutils.QueryRunner.fillStatement(QueryRunner.java:176)
at org.apache.commons.dbutils.QueryRunner.query(QueryRunner.java:392)
at org.mule.transport.jdbc.sqlstrategy.SelectSqlStatementStrategy.executeStatement(SelectSqlSt atementStrategy.java:80)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)

Is there any differences between calling MySQL and SQL Server when it comes to invoke variables and parameters in the query?

<jdbc:connector name="db_conn_f102" dataSource-ref="f102" pollingFrequency="5000" doc:name="Database" validateConnections="false">
    <jdbc:query key="read" value="SELECT ID , #[header:INBOUND:company] as company FROM AcTr"/>
</jdbc:connector>

<jdbc:connector name="db_conn_f100" dataSource-ref="f100" pollingFrequency="5000" doc:name="Database" validateConnections="false">
    <jdbc:query key="readickr" value="SELECT ID, #[header:INBOUND:company] as company FROM AcTr"/>
</jdbc:connector>

Upvotes: 1

Views: 1783

Answers (1)

David Dossot
David Dossot

Reputation: 33413

There's no difference in variable resolution in queries as far as database type is concerned.

I reckon the issue is that the generate SQL query is not syntactically correct for SQL Server. Like: is it legal to use a bound variable in the SELECT part of a query with SQL Server?

Upvotes: 1

Related Questions