1

In my program I am sending SQL query Dynamic to my report (Jasper Reports) ,But the problem the sql query dynamic work just in main DataSet for report , don't work in sub DataSet for table or list in jasper Report:

enter image description here

Is there a way to make the sql query Dynamic this send from java working in sub DataSet for table or list ?

this my code that Contain the sql query Dynmic that send to my report (jasper reports ) it's working just in Main DataSet .


try {
    String date1="2017-07-23";
    String date2="2017-07-27";
    Connection con=dbcontt.getconction();
    String sql="SELECT `name_hazj`, `sex_hazj`, `age_hazj`, `id_card_hazj`, `date_hazj` FROM `sike_hajaz_list` WHERE `date_hazj` BETWEEN '"+date1+"' AND '"+date2+"' ORDER by date_hazj";
    JasperDesign jd=JRXmlLoader.load("bin/report/hajz_between_2.jrxml");
    JRDesignQuery newQuery=new JRDesignQuery();

            newQuery.setText(sql);
            jd.setQuery(newQuery);
            JasperReport js;

            js=JasperCompileManager.compileReport(jd);
            JasperPrint jasperPrint=JasperFillManager.fillReport(js, null,con);

            JasperViewer.viewReport(jasperPrint,false);

} catch (JRException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
} catch (ClassNotFoundException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
} catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}
Dave Jarvis
  • 30,436
  • 41
  • 178
  • 315
Younis
  • 35
  • 1
  • 6
  • Are you using any dummy query in jasper reports main data set ? If not , you have to set propety as shown here https://stackoverflow.com/questions/9567422/jasper-ireport-table-returns-an-empty-document-although-query-works/29035178#29035178 I hope this will help you. – Fahad Anjum Jul 28 '17 at 06:52

0 Answers0