Jasper report missing first row

Please post your jrxml file.

The problem might not be in your code.

In Jasper, the record pointer in the data source is incremented by every element that receives it (so, for exemple, if you in the report you have a table and you set the datasource of the table as being the datasource of the report it will skip the first record. If this is the case, you have to pass the datasource from the report as a parameter to the table).

UPDATE:

1.Send your datasource from the server as a parameter, and fill the report with a different one (can be empty).

2.Decalre a new parameter in the report of same type as your bean collection, let's name it 'DS1'.

3.Set TableDatasource to use the $P{DS1} parameter.

See my response to How to show JRBeanCollectionDataSource data with help of Table component? for an example.


As Laura mentioned in this answer the record pointer in the data source is incremented by every element that receives it. Since I'm passing the result set, I thought no point in passing result set again as a parameter. Finally I decided to add an empty record at the beginning of the result set.

In getReportData method in above question, you can do it by, following below method.

    RowSet rowSet = namedParameterJdbcTemplate.query(query, params, new ResultSetExtractor<RowSet>() {
            @Override
            public RowSet extractData(ResultSet resultSet) throws SQLException, DataAccessException {

                OracleCachedRowSet rs = new OracleCachedRowSet();
                rs.populate(resultSet);

                // Have to add a empty row, because jasper is not displaying
                // the first row of report.
                rs.setReadOnly(false);
                rs.beforeFirst();
                rs.moveToInsertRow();

                int numCol = rs.getMetaData().getColumnCount();
                for (int i = 1; i < numCol + 1; i++) {
                    // Add null inserted row to each column
                    rs.updateNull(i);
                }

                rs.insertRow();
                rs.beforeFirst();
                return rs;
            }
        });