Details
Description
I have a similar problem to the problem described in CAMEL-18399 but instead of the result of getParameterMetadata returning null it is throwing an exception from the driver. The driver is com.microsoft.sqlserver/mssql-jdbc/11.2.1.jre11 although all version are affected as far as I can tell. It looks like a bug in their parser where it fails to parse for valid queries when there are parameters. Where it affects me the most is when sql-92 join syntax includes a parameter, like
select 'x' from TABLEA A JOIN TABLEB B on A.F1 = B.F1 and B.F2 = :#parm1 WHERE A.F1 = :#parm2
Including the parametersCount option doesn't help in this case as it doesn't bypass the getParameterMetadata. My proposal is to only call getParameterMetadata if the parametersCount isn't set because it is only being used to populate the expected variable anyway.