Jump to content
Changes to the Jaspersoft community edition download ×

Problem with parameter passing to queryString


Recommended Posts


I'm using JesperReports Library and I'm trying to filter sql query. Unfortunately parameter is ignored and default value from <defaultValueExpression> is always used. Even if I would delete <defaultValueExpression> with its value It will never return correct result (Empty result every time). Part of my code is pasted below.


.jrxml code

<subDataset name="tableDataset" uuid="ad14c38d-49b3-49db-a2f7-1d24458f7e5f">   <property name="com.jaspersoft.studio.data.defaultdataadapter" value="New Data Adapter "/>   <parameter name="queryParam" class="java.lang.Integer">      <defaultValueExpression><![CDATA[210]]></defaultValueExpression>   </parameter>   <queryString language="SQL">      <![CDATA[sELECT * FROM skd where skd_km = $P{queryParam}]]>   </queryString>   <field name="skd_id" class="java.lang.Integer"/>   <field name="skd_nd"/>   <field name="skd_km" class="java.lang.Integer"/>   <field name="skd_m" class="java.lang.Integer"/>   <field name="skd_odc" />   <field name="skd_kod" class="java.lang.Long"/>   <field name="skd_nr" class="java.lang.Integer"/>   <field name="skd_pkt" class="java.lang.Integer"/></subDataset>


.java code

        try (Connection conn = DriverManager.getConnection(dbURL, username, password)) {            JasperReport jasperReport = JasperCompileManager.compileReport(                    "src/main/resources/tempSKDFiltered.jrxml");            Map<String, Object> parametersMap = new HashMap();            parametersMap.put("queryParam", 229);            JasperPrint jasperPrint = JasperFillManager.fillReport(                    jasperReport, parametersMap, conn);            JasperExportManager.exportReportToPdfFile(                    jasperPrint, "SKDFilter.pdf");        } catch (JRException e) {            e.printStackTrace();        } catch (SQLException e) {            e.printStackTrace();        }    }


Does anybody have an idea what I'm doing wrong?



Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...