Java Reference
In-Depth Information
connection = DriverManager.getConnection("jdbc:mysql:
//localhost:3306/flightstats?" + "user=user&password=secret");
System.out.println("Filling report...");
JasperFillManager.fillReportToFile(reportDirectory + "/" +
reportName + ".jasper", parameterMap,connection);
System.out.println("Done!");
connection.close();
}
catch (JRException e)
{
e.printStackTrace();
}
catch (ClassNotFoundException e)
{
e.printStackTrace();
}
catch (SQLException e)
{
e.printStackTrace();
}
}
public static void main(String[] args)
{
new DbConnectionReportFill().generateReport(args[0]);
}
}
JRFileVirtualizer has two constructors. The one we chose to use in the example
takes two parameters. The first parameter is the maximum number of report pages
that will be stored in primary memory (RAM) before sections of the report are stored
in virtual memory (disk), and the second parameter is the directory that will be used
to store the segments of the report that will be stored on disk. The other constructor
takes a single parameter, an int indicating the maximum number of report pages that
will be stored in primary memory. When using this constructor, the cached portions
of the report will be stored in the running application's working directory. We need to
do nothing special in the JRXML template to be able to cache them to disk.
The process described in this section makes filling a report a much slower process
than usual. Therefore, report virtualization should be used only when there is a good
possibility that the report will cause the JVM to run out of memory.
 
Search WWH ::




Custom Search