Jaspersoft Studio Query Parameter Not Found

Posted on
Jaspersoft Studio Query Parameter Not Found 6,8/10 9635 reviews

I'm trying to write a query for my application, but I'm having some troubles. I need to pass as a parameter one field of my database, like:

Because WHERE clause and ORDER BY clause are dynamic for the user to select.

  1. Mar 09, 2016  I am trying to create a simple parameterised report in Jaspersoft Studio - following the steps set out in CA's. Skip navigation. I've added the required parameters and the query parameters in the design, successfully deployed it to the server, and added the following input controls to the report. 1 person found this.
  2. When using a parameter in a query, a default value must be set for the parameter to allow Jaspersoft Studio to execute the query to retrieve the available fields.

I am passing parameters to Jaspersoft report to generate reports Dynamically. When I executed same query against DB it. Newest jaspersoft-studio questions feed.

Jaspersoft Studio Query Parameter Not Found

Using $P{} it didn't work.

Ricardo AbbariRicardo Abbari

2 Answers

There are two syntax expressions for parameter referencing in JasperReports: $P{} and $P!{}.

  • $P{paramName} syntax is using mostly for setting WHERE input parameters values. The replacement algorithm is 'smart', its implementation uses java.sql.PreparedStatement: for java.lang.String parameter the engine will replace $P{parameterName} with quoted value, for java.lang.Integer - with numeric value and so on.

The sample:

Original expression (to replace):

The result will be:

  • $P!{paramName} syntax is using mostly for doing the 'simple' replace.

The sample:

Original expression (to replace):

The result will be:

For more information you can read this Using report parameters post and look at this Query sample.

In your case the right expression may be like this:

where $P{key} is a java.lang.String parameter

or like this (it depends on $P!{clause} value)

where $P{key} is a java.lang.String parameter

Alex KAlex K
Query
Singha BoonhongSingha Boonhong

Not the answer you're looking for? Browse other questions tagged sqljasper-reportsparameter-passing or ask your own question.

'<'jasperReport xmlns='http://jasperreports.sourceforge.net/jasperreports' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd' name='productsExport' pageWidth='595' pageHeight='842' columnWidth='555' leftMargin='20' rightMargin='20' topMargin='20' bottomMargin='20' uuid='b6f96e0c-32ea-431c-b1db-cf8582bb9a6f'>

user3454604
user3454604user3454604

1 Answer

Although it's not very detailed info, I think you have an error when try to compile (preview) your report in Jaspersoft Studio / iReport which sais: 'Field not found: desrciption ---- net.sf (blabla)'

Very simple to fix: It only occurs( for as far as I know) when you have a reference in your report (example a Text Field) to a field from the Dataset (SQL query or manual field) that isn't there anymore.Probably a new query, updated the fields and the field 'Description' dissappeared.

How to solve:

  • Remove the reference (Text Field probably) in your report with '$F{description}. OR
  • Update Dataset (SQL Query) so that if has the field 'description' as a result OR
  • (Ugly, not usefull but working): Add the field manually
Gert OussorenGert Oussoren

Not the answer you're looking for? Browse other questions tagged jasper-reports or ask your own question.