Have any questions?
+44 1234 567 890
In this post we set the basis for many of the upcoming tutorials. We will show you how to load the democontent into ReportServer’s internal database so that we can later base our reporting tutorial on some data. We assume that you have ReportServer up and running which should be the case after following the quick install guide.
Note: this tutorial describes the setup of the demo database in ReportServer 2.0. Since version 2.1 the configuration has moved to the internal filesystem (file /fileserver/etc/datasources/internaldb.cf). You’ll find a detailed description of the new configuration layout in the ReportServer configuration guide. Note that the installdemodata property will only take effect, after a restart of ReportServer. To load the demo data during runtime you can alternatively use the following script:
import net.datenwerke.rs.core.service.internaldb.InternalDbService GLOBALS.getRsService(InternalDbService.class).initDemoDatabase()
To execute the script, copy the two lines to a file beneath the bin directory. Then open the terminal (ctrl+alt+t), go to the directory to where you placed the script (for example “cd /fileserver/bin/tmp”) and execute the script via “exec theScriptsName”.
ReportServer comes with a running internal H2 database that it uses to, for example, cache data coming from static datasources such as a CSV datasource. We figured, that it might also be nice for demo purposes to allow for loading some demo content into this database on ReportServer startup. For this, all you have to do is to set a couple of properties in ReportServer’s external configuration file reportserver.properties (located in WEB-INF/classes). Here you will find a couple of properties related to the internal database:
# rs.internaldb.location = dbtmp
# The location of the database files
rs.internaldb.location = dbtmp
# rs.internaldb.encryption.disable = false
# set to true to disable file encryption
rs.internaldb.encryption.disable = false
# rs.internaldb.encryption.password = SecretPassphrase
# Password for file encryption (may not contain spaces)
rs.internaldb.encryption.password = SecretPassphrase
# rs.internaldb.root.password
# Password of root use (may not contain spaces)
rs.internaldb.root.password = RootsSecretPassphrase
# rs.internaldb.installdemodata
#
rs.internaldb.installdemodata = true
Note for version 2.1: a sample config file (/fileserver/etc/datasources/internaldb.cf) for ReportServer 2.1 could look like:
<configuration> <internaldb> <location>dbtmp</location> <encryption> <disable>false</disable> <password>SecretPassphrase</password> </encryption> <installdemodata>true</installdemodata> </internaldb> </configuration>
The first one and the last one are the truly important here. But let’s go through them property by property. The first propety defines where the database is located. As it is written, it would be in a folder “dbtmp” relative to the webapp. Be sure to create that folder and allow ReportServer (that is Tomcat or whatever application server you are running) write access to it. Via the second property you can turn of database encryption. Let’s leave it on for the moment, that is, keep disable set to false. The next property is only used if the database is encrypted and contains the password used for the file encryption. The second to last property specifies the password of user root. Finally, the last property tells ReportServer to load the demodata on startup.
Our demodata builds on the demodata provided by the Eclipse Birt project (http://www.eclipse.org/birt/phoenix/db/). We’ve added some aggregated views on the data to allow for nice and easy reporting. The demodata contains business data of a fictional toy producer. We have customer data, order records and the likes.
Setting up the data connection within ReportServer
With the external propeties set, you can fire up ReportServer. If everything goes smoothly you should see the following info line in your logs
demodata imported
Note that loading the data can take a few moments, so be patient. If you log into ReportServer the next step is to configure a database connection to the internal database containing the demodata. For this go to the administration module and then to the datasource manager. We add a new datasource (right click on the folder) of type “relational database”. We name the datasource “Test” and select “H2” as database type. The democontent is accessible via user “demo” with password “demo”. Finally, as jdbc URL set
jdbc:h2:PATH-TO-DATABASE/rsdemodb;AUTO_SERVER=TRUE
where PATH-TO-DATABASE should be an absolute path to the folder you configured earlier. The connection option “AUTO_SERVER=TRUE” ensures that multiple connections can access the data simultaniously. Click “Apply” to store the changes to the datasource object.
To see if everything has worked click on “test connection” from the toolbar. If everything worked you should see the message
The connection test was successful.
We can now create a simple dynamic list, backed by the demo content.
A customer list
To create the dynamic list we go to the report manager (in the administration module) and create a new report of type dynamic list. Let’s name the report “Customer List” and select our newly created datasource. As query we simply use
SELECT * FROM T_AGG_CUSTOMER
The pageshould now look somewhat like this.
Hit apply, and let’s have a look at the result. To open the report, simply double click on the corresponding node in the tree. The list configuration view is opened. To select columns for the report, click on “select columns” and drag some columns from the left to the right column.
Select “preview” from the left menu to get an idea of what the report looks like. To export the report to, for example, Excel click on “Excel-Export” in the toolbar. You can also save the report as a variant. This safes all the metadata such as selected columns, filters, parameters etc. To save your selection as a variant, hit save from the toolbar.
That is it, for today. We have installed the democontent and are thus ready for further and more advanced tutorial. Be sure to check our tutorial page as well as our forum from time to time to hear about any news on ReportServer.