13.07.2015 Views

iReport Ultimate Guide - Nimsoft Library

iReport Ultimate Guide - Nimsoft Library

iReport Ultimate Guide - Nimsoft Library

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>iReport</strong> <strong>Ultimate</strong> <strong>Guide</strong>of particular data. For this reason, UR puts at your disposal a special parameter named REPORT_CONNECTION of thejava.sql.Connection type; it can be used in whatever expression you like, with a parameters syntax as follows:$P{REPORT_CONNECTION}This parameter contains the java.sql.Connection class passed to UR from the calling program.The use of JDBC or SQL connections is the simplest and easiest way to fill a report. The details for how to create a SQL queryare explained in Chapter 6.11.4.1 Fields RegistrationIn order to use SQL query fields in a report, you need to register them. It is not necessary to register all the selectedfields—only those effectively used in the report are enough. For each field, you must specify its name and type. Table 11-1shows the mapping of the SQL types to the corresponding Java types.Table 11-1Conversion of SQL and JAVA typesSQL Type Java Object SQL Type Java ObjectCHAR String REAL FloatVARCHAR String FLOAT DoubleLONGVARCHAR String DOUBLE DoubleNUMERIC java.math.BigDecimal BINARY byte[]DECIMAL java.math.BigDecimal VARBINARY byte[]BIT Boolean LONGVARBINARY byte[]TINYINT Integer DATE java.sql.DateSMALLINT Integer TIME java.sql.TimeINTEGER Integer TIMESTAMP java.sql.TimestampBIGINTLongThe table does not include the BLOB and CLOB types and other special types, such as ARRAY, STRUCT, and REF, becausethese types cannot be managed automatically by UR. However, it is possible to use them by declaring themgenerically as Object and managing them by writing supporting static methods. The BINARY, VARBINARY, andLONGBINARY types should be dealt with in a similar way. With many databases, BLOB and CLOB can be declared asjava.io.InputStream.Whether a SQL type is converted to a Java object depends on the JDBC driver used.For the automatic registration of SQL query fields, <strong>iReport</strong> relies on the type proposed for each field by the driver itself.11.4.2 Sorting and Filtering RecordsThe records retrieved from a data source (or from the execution of a query through a connection) can be ordered and filtered.Sort and filter options may be set from the Report query dialog box by clicking Filter Expressions and Sort Options and (seeFigure 11-11).180

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!