### Configuring the server database when integrating with an application server

JReport Enterprise 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 Enterprise Server can get the predefined javax.sql.DataSource by JNDI APIs.

Here, the term dsInfo is used to indicate where JReport Enterprise Server can obtain the JDBC connection information. It is a key-value pair. The name and value for dsInfo are defined as below:

- The name should be: jreport.datasource.<dbname>.

  Where,

  <dbname> is JReport Enterprise Server's inner database name. It must be systable or profiling. For example, the dsInfo name is jreport.datasource.systables.

- The value should be in the form of a URL. There are three protocols supported by JReport Enterprise Server:
  - `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-systables#driver=sun.jdbc.odbc.JdbcOdbcDriver`

  - `jndi://[<jdbc-user:jdbc-passoword>@]datasource_name[#<attribute-name=attribute-value>,]`

    For example: `jndi://jdbc/jreport-systables`

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 jreport.ear file that JReport Enterprise Server creates does not specify any Java EE information. By default it will load from the dbconfig.xml file.
- There is a limitation in WebSphere. JReport Enterprise Server's dsInfo can be configured to the WEB-INF/web.xml with JNDI name but not RESOURCE name. JBoss works fine for either one.
- Do not use reporthome, @ or # in the JNDI name or Resource name.

The following sections focus on specifying the dsInfo in web.xml, ejb-jar.xml, and dbconfig.xml:

- Specifying data source in web.xml (for the WAR mode)
- Specifying data source in ejb-jar.xml or web.xml (for EAR mode)
- Specifying data source in dbconfig.xml