To be able to preview and export the report samples, the following data sources must be configured first (see Section 3.2, “Data Sources”):
Procedure A.2. Configuring JasperAssistant
Empty Data Source
Create an empty data source with one record (Size 1) named Samples
Empty
.
Database Data Source
Create a database data source named Samples Database
with
the following configuration:
Driver: org.hsqldb.jdbcDriver
URL: jdbc:hsqldb:c:/jasperreports/demo/hsqldb/test
Username: sa
JAR file 1:
C:\jasperreports\lib\hsqldb-1.61.jar
XML Data Source
Create an XML data source named Samples XML
with the
following configuration:
XML file: C:\jasperreports\demo\samples\xmldatasource\northwind.xml
XPath select: /Northwind/Customers
Custom Data Source
This data source is optional as it requires a less trivial configuration.
This data source is required by the DataSource
sample. If
you do not plan to use custom data sources then you can skip this
configuration step.
Create a Java class named CustomDataSourceProvider
with the
following source:
import net.sf.jasperreports.engine.JRDataSource; import net.sf.jasperreports.engine.JRException; import net.sf.jasperreports.engine.JasperReport; import net.sf.jasperreports.engine.data. JRAbstractBeanDataSourceProvider; import net.sf.jasperreports.engine.data. JRBeanArrayDataSource; public class CustomDataSourceProvider extends JRAbstractBeanDataSourceProvider { public CustomDataSourceProvider() { super(CustomBean.class); } public JRDataSource create(JasperReport report) throws JRException { return new JRBeanArrayDataSource( CustomBeanFactory.getBeanArray()); } public void dispose(JRDataSource dataSource) throws JRException { // nothing to dispose } }
Create a custom data source named Samples Custom
with the
following configuration:
Java project: samples
Provider class: CustomDataSourceProvider