Specifying Connections in datasource.xml
You can conveniently set different connections in Logi Report Server, using a configuration file datasource.xml. This topic describes how you can modify the content of datasource.xml, reload connection information from the file, integrate Logi Report Server into your application server with the updated datasource.xml, and use JNDI data source connections of WebLogic and JBoss Servers.
You can change the datasource.xml file to use another runtime JDBC or JNDI data source to run reports, depending on the data source your application uses. In this way, you can control the catalog data source connections in Logi Report Server to dynamically connect to your production data sources.
You can find the file datasource.xml in the <install_root>\bin
directory. Change this file according to the data source you want to use. You can set two types of connections in Logi Report Server: JNDI data source connection and JDBC connection.
This topic contains the following sections:
- Contents of datasource.xml
- Reloading Connection Information from datasource.xml
- Integrating Logi Report Server with Your Java Application Server
- Example 1: Using JNDI Data Source Connections of WebLogic Server
- Example 2: Using JNDI Data Source Connections of JBoss Server
Contents of datasource.xml
You can add multiple <datasource></datasource> tags in datasource.xml. Each pair will map one of the connections in your catalog. You can define mapping connections for multiple connections for more than one catalog. The catalog connection name should be unique in the datasource.xml file, otherwise the latter <datasource> information will overwrite the previous ones.
The content of the datasource.xml file is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<datasource-mapping>
<datasource>
<catalog-connection-name>Connection1</catalog-connection-name>
<connection-type>JNDI</connection-type>
<jndi-datasource>Sample</jndi-datasource>
</datasource>
<datasource>
<catalog-connection-name>Connection2</catalog-connection-name>
<connection-type>JDBC</connection-type>
<driver>sun.jdbc.odbc.JdbcOdbcDriver</driver>
<url>jdbc:odbc:jinfonet</url>
<user>Username</user>
<password>Password</password>
</datasource>
</datasource-mapping>
Element descriptions
- catalog-connection-name
Specifies the name of the catalog connection that you want to substitute.This is the connection name that you can see in the Logi Report Designer Catalog Manager. A unique connection name in a catalog is suggested.
- connection-type
Specifies the connection type, which can be either JNDI or JDBC. - jndi-datasource
If you are using a JNDI data source, specify the JNDI data source name you defined in your Java application server which you want to use as the substitute connection. - driver & url
If you are using a JDBC data source, specify the JDBC Driver and URL in these two attributes. - user & password
Specifies the user name and the password.The <user> and <password> information is encrypted. The <user> and <password> tags will be replaced by the <encrypt-sign> tag after Logi Report Server's startup as follows:
<encrypt-sign>enDkq7srM9cHhoUwzYXJ3NvcDIYk</encrypt-sign>
If you want to change user or password, delete the <encrypt-sign> tag and add the <user> and <password> tags in the datasource.xml file.
You can choose whether to provide database user and password information for the JNDI connection, using the <user> and <password> tags. If the user and password information is provided in this file, it will be used to set up the connection regardless of the settings defined in your application server. Otherwise, the settings defined in your application server will be used. Specially, for WebLogic users, you should provide user name and password for WebLogic console instead of the database.
- refresh-support-info
Optional. If it is true, Logi Report will get support information including reverse words, quote characters, and so on from the driver each time fetching data from the database. If it is not set, the property will be treated as false. You should set this property to true when connecting to a different database. - quote-character
Optional. Specifies the quote characters. - extra-characters
Optional. Specifies the extra characters. - date-format
Optional. Specifies the date format. - datetime-format
Optional. Specifies the datetime format. - time-format
Optional. Specifies the time format. - transaction-readonly
Optional. Specifies the transaction "read only" property. Possible value: default, Read only, or Read&Write. Ignore other values. - transaction-mode
Optional. Specifies the transaction mode. Possible value: default, None, Read Uncommitted, Read Committed, Repeatable Read, or Serializable. Ignore other values. - char-to-be-replaced
Optional. Specifies the characters that are to be replaced. - char-replaced-by
Optional. Specifies the characters used to replace the characters specified by char-to-be-replaced.
Reloading Connection Information from datasource.xml
After you have made changes to the datasource.xml file, you need to reload it in Logi Report Server, using either of the following ways:
- In the Server Console, go to the Administration > Connection > Reload Connection page, and then select the Reload button.
- Call jet.server.api.admin.ConnectionInfoProviderService.reloadFile().
Integrating Logi Report Server with Your Java Application Server
After updating the datasource.xml file, you can integrate Logi Report Server with your application server.
If you are using a WAR file, make sure to include the datasource.xml file in the WAR file. To do this,
- Before making the Logi Report Server WAR file, in makewar.xml in the
<install_root>\bin
directory, add<include name="datasource.xml" />
into the<zipfileset dir="${installroot}/bin" prefix="workspace/bin">
section. - Before you deploy the WAR file to a web server, make sure to include the datasource.xml file in the
jreport.war/WEB-INF/lib/jrenv.jar/workspace/bin
directory.
If you are integrating Logi Report Server to an application using a non-Logi Report WAR file, usually you need to specify the -Dreporthome parameter in the application server so that the application server can locate and load the resources it needs. Since the datasource.xml already exists in the bin directory, you do not need to do anything special for this file.
Example 1: Using JNDI Data Source Connections of WebLogic Server
Using WebLogic as an example, take the following steps:
- Start WebLogic server, navigate to <YourProjectName> > Services > JDBC > Connection Pools. In the Configuration tab, make sure that the connection you are going to use is there and correctly set up.
- Browse to <YourProjectName> > Services > JDBC > Data Sources. In the Configuration tab, create a data source using the JNDI name MyJNDISample. Select the correct connection from the Pool Name drop-down list.
- Open datasource.xml in the
<install_root>\bin
directory and add the following:<datasource-mapping>
<datasource>
<catalog-connection-name>ConnectionName</catalog-connection-name>
<connection-type>JNDI</connection-type>
<jndi-datasource>MyJNDISample</jndi-datasource>
<user>youruserid</user>
<password>yourpassword</password>
</datasource>
</datasource-mapping> - Build the Logi Report Server WAR file using the makewar utility in the
<install_root>\bin
directory. - Deploy Logi Report Server to WebLogic.
- Run the report that uses this connection.
Example 2: Using JNDI Data Source Connections of JBoss Server
Using JBoss as an example, in this Example, DB2 is used, and JBoss is installed to D:\jboss-4.0.1
. Take the following steps:
- Copy the DB2 driver to
D:\jboss-4.0.1\server\default\lib
. - Create a db2-ds.xml file in
D:\jboss-4.0.1\server\default\deploy
, and add the following content:<?xml version="1.0" encoding="UTF-8"?>
<datasources>
<local-tx-datasource>
<jndi-name>DB2DataSource</jndi-name>
<connection-url>jdbc:db2://dbs-b/sample</connection-url>
<driver-class>com.ibm.db2.jdbc.net.DB2Driver</driver-class>
<user-name>db2admin</user-name>
<password>db2admin</password>
<min-pool-size>0</min-pool-size>
<metadata>
<type-mapping>DB2</type-mapping>
</metadata>
</local-tx-datasource>
</datasources> - Modify datasource.xml in
<install_root>\bin
to include the following:<datasource-mapping>
<datasource>
<catalog-connection-name>ConnectionName</catalog-connection-name>
<connection-type>JNDI</connection-type>
<jndi-datasource>java:/DB2DataSource</jndi-datasource>
</datasource>
</datasource-mapping> - Build the Logi Report Server WAR file using the makewar.bat utility in the
<install_root>\bin
directory. - Deploy Logi Report Server to JBoss.
- Run the report that uses this connection.