title: Using DynamicJasper API: Getting empty report with crosstab
body: <p>I try to create dynamic <em>crosstab</em>. When I try, I have an error <a href="https://stackoverflow.com/questions/12317912/java-lang-classcastexception-jasper-report-crosstab">java.lang.ClassCastException Jasper Report Crosstab</a> than I solved it. But my report is empty. I don't get it why. I check my result set is empty or not. But it does not empty.</p>
  
  <p>Here is my code:</p>
  
  <pre class="lang-java prettyprint-override"><code>public class DynamicJasperTemplate{
  .....//variables define here    
  
  public void buildReport() throws Exception{
      ....//I create query here and get row column and measure field name
      JRDataSource ds = getDataSource(query,a,b,c);//I get data from db as jrdatasource
      DynamicReport dr = buildReportLayout(a,b,c,ds); // build report layout and add it crosstab in this method.
  
      params.put("sr",ds);//I set report parameter value
  
      JasperReport jr = DynamicJasperHelper.generateJasperReport(dr, new ClassicLayoutManager(), params);
      JasperPrint jp = JasperFillManager.fillReport(jr, params, ds);
      JasperExportManager.exportReportToPdfFile(jp,"C:/report-out.pdf");
  
  }
  
  private DynamicReport buildReportLayout(String[] a,String[] b,String[] c, JRDataSource ds) {
      FastReportBuilder drb = new FastReportBuilder();
      drb.setWhenNoDataAllSectionNoDetail();
      initStyles();
      CrosstabBuilder cb = new CrosstabBuilder();
  
  
      cb.setHeight(200)
                  .setWidth(500)
                  .setHeaderStyle(mainHeaderStyle)
                  .setDatasource("sr",DJConstants.DATA_SOURCE_ORIGIN_REPORT_DATASOURCE, DJConstants.DATA_SOURCE_TYPE_JRDATASOURCE)
                  .setUseFullWidth(true)
                  .setColorScheme(4)
                  .setAutomaticTitle(true)
                  .setCellBorder(Border.PEN_1_POINT());
  
      Object obj="NUMBER";
      Object obj1="VARCHAR2";
      String type = null;
      for(int i=0; i&lt;a.length; i++) {
          DJCrosstabRow row = new CrosstabRowBuilder().setProperty(a[i],String.class.getName())
                              .setHeaderWidth(100).setHeight(0)
                              .setTitle(a[i])
                              .setShowTotals(true).setTotalStyle(totalStyle)
                              .setTotalHeaderStyle(totalHeader).setHeaderStyle(colAndRowHeaderStyle)
                              .build();
          cb.addRow(row);
      }
  
      DJCrosstabColumn col =new CrosstabColumnBuilder().setProperty(b.toString(),"java.sql.Timestamp")
                                      .setHeaderHeight(60).setWidth(50)
                                      .setTitle(b.toString()).setShowTotals(true)
                                      .setTotalStyle(totalStyle).setTotalHeaderStyle(totalHeader)
                                      .setHeaderStyle(colAndRowHeaderStyle)
                                      .build();
      cb.addColumn(col);
      cb.addMeasure(c[0],"java.math.BigDecimal", DJCalculation.NOTHING , c[0],measureStyle);      
      djcross = cb.build();
      drb.addHeaderCrosstab(djcross);
      drb.setUseFullPageWidth(true);
      drb.addParameter("sr", "java.util.Collection");
  
      DynamicReport dr = drb.build();
      return dr;
  }
  
  
  private void initStyles() {
      ....//here ı define styles
  }
  
  
  
  private JRDataSource getDataSource(String query,String[] a,String[] b,String[] c) throws SQLException, JRException {
  
      Connection con = new getConnection().conn();
      List&lt;Map&lt;String, ?&gt;&gt; arr = new ArrayList&lt;Map&lt;String, ?&gt;&gt;();
      String columnValue;
      Map data = new HashMap();
      JRResultSetDataSource result = null;
      ResultSet rs = null;
      int i;
      try{
          if(con!=null){
                  Statement stmt = con.createStatement();
                  rs = stmt.executeQuery(query);  
                  JRDataSource ds = new JRResultSetDataSource(rs);
                  return ds;
          }
      ......
  </code></pre>
  
  <p>I hope you can tell me the what I make wrong.</p>