[#6526] - Bad interpretation of SQL-Query-comments

Bug report
Feedback Requested
Project: Severity:
Component: Reproducibility:
Assigned to:

If I include a comment (prefixed with -- as line or /* */ for multi-line) in my SQL-Query that includes a parameter, like for example -- $P{REPORT_CONTEXT}, the Jasperstudio SQL Parser seems to interpret this, it gives me the error "Invalid column index" although the query is completely correct. When I remove the comment, everything works fine.
So it seems to interpret the parameter expression within a comment, very confusing!

sibylle.koetzer's picture
Joined: Dec 2 2015 - 7:46am
Last seen: 7 years 3 months ago


  • Assigned:nobody» chicuslavic

could you add your query to the description?


Hello chicuslavic,
you can just use an example query (from the Sample DB) followed by a comment like that:

Select * from Address where city = 'Oslo'
-- now follows a comment with any parameter: $P{REPORT_CONTEXT}

Greetings, Sibylle

  • Assigned:chicuslavic» teodord
  • Assigned:nobody»

Can confirm. This is a major problem. Which version will it be resolved in?

  • Status:New» Feedback Requested
  • Assigned:nobody» teodord


I think the problem is with SQL comments that contain $P{} and/or $!P{} references.
We do not parse the SQL queries for comments to eliminate such parameter references in comments, so there will be a mismatch when the parameter values are set on the JDBC statement.
Not sure if we want to go that far in parsing SQL queries to eliminate comments.

If this is indeed the situation you encounter, would it be too much to ask you that when you comment out entire sections of the SQL query, you also touch the $P{} and $!P{} references to disable them by adding some character to them so that the parameter parser no longer finds them in comments?
Something like:

$_P{} and $_!P{}

After all, they are comments, so you probably keep them around for later use. When uncommenting, just need to make sure you reactivate the parameter references by removing the disabling character.
Let's just say this would be the Jasper way of commenting out parameter references in queries.