Named query select statement throws com.microsoft.sqlserver.jdbc.SQLServerException: The index 1 is out of range

Very straightforward select query that accepts one value paramter (string) results in
com.microsoft.sqlserver.jdbc.SQLServerException: The index 1 is out of range.

Here is my query:
SELECT DISTINCT itemClassId, itemType + ’ – ’ + itemSubType as label
from imItemClass
WHERE itemSubType IS NOT NULL
AND itemCategory = ‘:itemCategory’
order by label

And the parameter itemCategory is a type = value and datatype = string

Solved it:

AND itemCategory = ‘:itemCategory’
should instead read:
AND itemCategory = :itemCategory – no quotes

2 Likes