Configuring the datasource.xml file
In order to enable you to conveniently set different connections in JReport Server, a configuration file, datasource.xml, is provided with which you can define the connection to use at runtime by setting up connection mapping information such as the JDBC driver, URL, or JNDI data source name, user and password, depending on the data source your application uses.
The datasource.xml file is located in the <install_root>\bin
directory. Change this file according to the data source you want to use. Two types of connections are supported by JReport Server. They are JNDI data source connection and JDBC connection.
There can be multiple <datasource></datasource> tags. 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. Note that this is the connection name that you can see in JReport Catalog Browser. 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 JReport 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, JReport 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. It is recommended that you 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.