JReport Server supports connecting an RDBMS to access its system data via JDBC. The JDBC configuration information is stored in the file dbconfig.xml in <install_root>\bin
. You can create a database connection according to this configuration file. Also, with the Java EE Data Source Support feature, in a Java EE environment, JReport Server can get the predefined javax.sql.DataSource by JNDI APIs.
Here, the term dsInfo is used to indicate where JReport Server can obtain the JDBC connection information. It is a key-value pair. The name and value for dsInfo are defined as follows:
file:///absolute_path_of_config_file
For example: file:///JReport/Server/bin/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 dsInfo can be specified in several places or levels, such as VM properties, ejb-jar.xml, web.xml and <install_root>\bin\dbconfig.xml. The sequence to load the information is:
VM system environment > ejb-jar.xml (EAR mode) > web.xml (WAR mode) > dbconfig.xml.
Notes:
The following shows specifying the dsInfo in web.xml, ejb-jar.xml, and dbconfig.xml respectively:
When integrating the JReport Server in a WAR package, you can specify the dsInfo in the WEB-INF/web.xml file using the <env-entry></env-entry>
or <context-param></context-param>
tags. However, the use of the <env-entry></env-entry>
tags is the recommended way since the tags are also supported in ejb-jar.xml (if you call the Server API in your EJB).
The following is an example of specifying the dsInfo in WEB-INF/web.xml using the <env-entry></env-entry>
tags:
|
The following is an example of specifying the dsInfo in WEB-INF/web.xml using the <context-param></context-param>
tags:
|
When the JReport Server is used with APIs by EJBs, you can specify the dsInfo either in the file ejb-jar.xml in /META-INF
or web.xml in /WEB-INF
.
For information about specifying a data source in the web.xml file, see section Specifying data source in web.xml (for the WAR mode).
Note: If the dsInfo is stored in a Web module, you should add the JReport Server context listener to the WEB-INF/web.xml file. Here is an example:
|
You can specify the dsInfo in the META-INF/ejb-jar.xml file using 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:
|
By default, JReport Server assumes that jreport.datasource.realmtables=file:///${rpthome}/bin/dbconfig.xml. You can specify either a JDBC or JNDI data source using the <datasource></datasource>
tags in the dbconfig.xml file.
For details about configuring the JDBC data source, see Configuring the server database in a standalone environment.
The following is an example of specifying the JNDI data source:
|