Sunday, September 21, 2014

Mule: No SQL Strategy found Issue in SQL Server


I was working on a Mule ESB process, when I came upon an error.

Root Exception stack trace:
java.lang.IllegalArgumentException: No SQL Strategy found for SQL statement: USE XXX_ServiceNow; SELECT LastEventId,LastEventTime FROM dbo.EVENTS_TRACKING;
at com.mulesoft.mule.transport.jdbc.sqlstrategy.EESqlStatementStrategyFactory.create(
at org.mule.transport.jdbc.JdbcMessageDispatcher.doSend(
at org.mule.transport.AbstractMessageDispatcher.process(
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)

I will admit this was one of the first times I had worked with SQL Server. I typically use everything except it, but I digress. I was attempting a simple query from a table, but getting back "No SQL Strategy..."


I had seen this error before, and what it means is that there essentially no SQL plan to be executed. In the original state. I was technically performing two operations.
1. Specifying which database to use.
2. Querying the table.
To solve my problem I needed to combine these two statements into a single statement.

The resulting code looked something like this:
SELECT <FieldName1>, <FieldName2>
FROM <DatabaseName>.<SchemaName>.<TableName>

No comments: