Specifying in the JVM system environment
When integrated with an application server, by default JReport Server obtains the server database information from dbconfig.xml located in the <server_install_root>\bin
directory. However, you can make use of a key-value pair to specify another database configuration file, or to specify the server database directly in a JDBC or JNDI data source.
The name of the key must be jreport.datasource.systemtables, jreport.datasource.realmtables, or jreport.datasource.profile, where systemtables, realmtables and profile are JReport Server's inner database names for the system database, realm database and profiling database respectively. The value should be in the form of a URL as one of the following:
file:///absolute_path_of_config_file
For example: file:///JReport/dbconfig.xml
, or file://D:\dbconfig.xml
jdbc://[<jdbc-user:jdbc-password>@]<jdbc-url>[#<attribute-name=attribute-value>,]
For example: jdbc://user:password@jdbc:odbc:jreport-realmtables#driver=sun.jdbc.odbc.JdbcOdbcDriver
jndi://[<jdbc-user:jdbc-passoword>@]datasource_name[#<attribute-name=attribute-value>,]
For example: jndi://jdbc/jreport-realmtables
The server database information can be specified in several places or levels, such as the system environment using -D
parameters, ejb-jar.xml, web.xml and dbconfig.xml. The sequence to load the information is:
system environment > ejb-jar.xml (EAR mode) > web.xml (WAR mode) > dbconfig.xml
To specify the key-value pair in the system environment, add the following -D
parameters in the JReport Server startup file JRServer.bat/JRServer.sh in the <server_install_root>\bin
directory:
-Djreport.datasource.profiling=file:///absolute_path_of_config_file,-Djreport.datasource.systemtables=file:///absolute_path_of_config_file,-Djreport.datasource.realmtables=file:///absolute_path_of_config_file
You can specify either a JDBC or JNDI data source using the <datasource></datasource>
tags in dbconfig.xml. Note that in dbconfig.xml, <database name
>
must be JReport Server's inner database name.
For details about configuring a JDBC data source, click here.
The following shows an example of specifying a JNDI data source:
|
When integrating JReport Server in a WAR package, you can specify the key-value pair in the WEB-INF/web.xml file using the <env-entry></env-entry>
or <context-param></context-param>
tags. The <env-entry></env-entry>
tags are more recommended since they are also supported in ejb-jar.xml if you call the Server API in your EJB.
The following example uses the <env-entry></env-entry>
tags:
|
The following example uses the <context-param></context-param>
tags:
|
When JReport Server is used with APIs by EJBs, you can specify the key-value pair either in META-INF/ejb-jar.xml or WEB-INF/web.xml.
To specify the key-value pair in META-INF/ejb-jar.xml, use the <env-entry></env-entry>
tags. For example, here is an EJB named firstEJB which creates the JReport Server instance. You can add the <env-entry></env-entry>
tags to the EJB's configuration file META-INF/ejb-jar.xml as follows:
|
If the server database information is stored in a Web module, you should add the JReport Server context listener to WEB-INF/web.xml as follows:
|
Notes: