Table of Contents
Jasper Server and Reports
Variable Tricks
Goal | Variable Class | Calculation | Example |
---|---|---|---|
All Rows | Integer | none | use built-in REPORT_COUNT |
Specific Fields | Integer | Count | $F{Field}.contains("RegEx") ? 1 : null |
Unique Fields | Integer | Distinct Count | $F{Field} |
Multiple Conditions | Integer | Count | $F{Field1}.contains("RegEx") && $F{Field2}.matches("Const") ? 1 : null |
Unique with Multiple Conditions | Integer | Distinct Count | ($F{Field1} + $F{Field2}).endsWith("Const") ? $F{Field1} : null |
Syntax - the '? TRUE : FALSE' conditional statement is shown above. What follows '?' is the output if the first statement is TRUE, if FALSE what follows :
is the output.
Count All Rows - the built-in variable REPORT_COUNT is a count of all rows. If data in a column is guaranteed to be unique then this variable will equal the total count.
Specific Fields - the example shows how to use a regular expression to evaluate field contents. The count is incremented by one every time the regular expression finds a match.
Unique Fields - the Distinct Count function outputs the number of unique occurrences. Useful if your dataset has duplicate values.
Multiple Conditions - the example shows how to require both statements to be TRUE (via &&
) in order to increment the counter.
Unique with Multiple Conditions - this example is a combination of the previous two. The important operator is that went TRUE the output is the Field that you want Distinct Count to evaluate.
Jasper Server Config
- Create work folder: /opt/jasper/work
- Copy Oracle JDBC driver ojdbc5.jar to /opt/jasper/jasperserver/apache-tomcat/common/lib/
- Copy MS SQL JDBC driver sqljdbc.jar to /opt/jasper/jasperserver/apache-tomcat/common/lib/
- Create Datasources for all datasources
- Edit /opt/jasper/jasperserver/jasperctl.sh
- Add
--max_allowed_packet=16M
to 'MYSQL_START'
- Edit /opt/jasper/jasperserver/apache-tomcat/bin/catalina.sh
- Add
CATALINA_OPTS="-Djava.awt.headless=true"
iReports Config
- Add Oracle JDBC drivers
- Tools, Options
- Classpath, add /usr/lib/oracle/{<ver>}/client/lib/ojdbc5.jar
- Add MS SQL JDBC drivers
- Tools, Options
- Classpath, add
/usr/lib/sqljdbc_<ver>/enu/sqljdbc.jar
- Create Datasources
Server 500 error
- Stop jasperserver:
/etc/init.d/jasperserver stop
- Clear out Tomcat work dir:
rm -rf /opt/jasper/jasperserver/apache-tomcat/work/
- Restart jasperserver:
/etc/init.d/jasperserver start
Jasper Server Install
- Download bin file
- Run bin file as root
- Install folder = /opt/jasper/jasperserver
- Use bundled Tomcat
- Use bundled MySQL
- Use default ports
- Install sample reports
- Install iReport
- Install Oracle client
iReports Install/Upgrade
- Installed with Jasper Server
- Upgrade
- Untar into /opt/jasper/jasperserver
- Move symlink from old version to new version
ln -sf /opt/jasper/jasperserver/iReport-New_Ver /opt/jasper/jasperserver/ireport
- Import settings from old version to new version – Tools, Import Settings
- Manual method = copy ireport.properties in home directory from old ver to new ver