Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 4 Next »

How can I configure the logging/How to turn off debugging messages

Logging is controlled by the JFreeReport configuration. You can tweak the configuration by creating a 'jfreereport.properties' file, putting that into the root of your classpath (the 'default' package, or for instance WEB-INF/classes, if you're in a Servlet-Container).

The Log-Level is controlled by the property 'org.jfree.base.LogLevel', which can have the one of the following values: 'Debug', 'Info', 'Warn', 'Error'. The log-level should be at least at Warn so that you receive information on non-critical errors (like missing column names, etc.) which do not cause the reporting to fail, but may indicate an error in the report definition file.

# The minimum loglevel that is logged.
org.jfree.base.LogLevel=Info

In the very unlikely case that you dont want to log to System.out and want to use a different logging mechanism, you can switch the logger implementation using the configuration as well.

To use Log4J, use

org.jfree.base.LogTarget=org.jfree.logger.log4j.Log4JLogTarget

We also support Jakarta-Commons (org.jfree.logger.jcl.JakartaLogTarget) and JDK14 style logging (org.jfree.logger.java14.Java14LogTarget). These log-target implementation can be found in the JCommons-Logging package. (Downloadable at http://www.jfree.org/jcommon/download/ )

How to include Definitions from the Pentaho Report-Wizzard or Pentaho Report-Designer into Swing Applications

The scope of Pentaho Reporting's development is primarily focused on generating great content in an easy way. Therefore Pentaho Reporting does not come with any automatic query-management, like the Pentaho-Plattform does.

The scope of Pentaho Reporting's development is primarily focused on generating great content in an easy way. Therefore Pentaho Reporting does not come with any automatic query-management, like the Pentaho-Plattform does. The Pentaho-Plattform, for now, does not come with the ability to start Pentaho Reporting's GUI.

Using MDX-Queries without the Plattform is hard, if not impossible. Including JDBC-Queries, however, is easy and can be done in a few lines of code.

This manual coding is ugly and will change sooner or later.

Both GUI tools generate an XAction and a report definition file. The XAction file describes how the Pentaho-Plattform prepares the report and which parameters are needed to configure the report processing.

Important: The Report-Designer uses an abstract report definition model as internal storage format. These definitions have the extension '.report'. Pentaho Reporting cannot understand these files - you have to export the report to generate the '.xml' file (the Pentaho Reporting report definiton) and the corresponding action sequence.

You can safely ignore that file, except for one thing: It also contains the SQL-Query string that is needed to get the data for the report. So fire up your favourite XML or Text-editor and extract the query string. (It is contained in an element <query> inside the action-definition.)

The code to get a JDBC-ResultSet is standard JDBC code, there's nothing special here. Get a connection, create a statement and fire the query.

public ResultSet performQuery(String query)
{
  final Properties prop = new Properties();
  prop.setProperty("user", "sa");
  prop.setProperty("password", "");

  // Note: You have to provide your own URL here
  final Connection c = DriverManager.getConnection
          ("jdbc:hsqldb:/home/src/pentaho/pentaho-jfree/sql/sampledata", prop);
  final Statement s = c.createStatement();
  final ResultSet resultSet = s.executeQuery(query);
  return resultSet;
}

Now we have the data, but Pentaho Reporting needs TableModels to work with. So let's wrap that resultset into a TableModel. The ResultSetTableModelFactory is part of Pentaho Reporting's core code.

final CloseableTableModel model =
    ResultSetTableModelFactory.getInstance().createTableModel(resultSet);

The ".xml" file the tools created contain your report definition. Copy that file into a suitable location and obtain an URL to that xml-file. Use the 'executeReport' method from above together with your URL and the tablemodel and execute the report. After the reporting, don't forget to close the TableModel to free the ResultSet.

  • No labels