Setting the Database Connection Parameters

You can configure your connection to the database in one of two ways:

You can configure the connection during installation of JasperReports Server by configuring the external.jdbcDriverClass, external.jdbcUrl, external.dbUsername, and/or external.dbPassword properties prior to installation or upgrade. At this time, you can optionally choose to encrypt any of the database connection parameters. This is the preferred method for setting the database connection parameters. See the JasperReports Server Administrator Guide for more information.
If you have an existing JasperReports Server, you can configure the connection properties directly in your sample-applicationContext-externalAuth-db-mt.xml file. In this case, the properties, including the password, cannot be encrypted.

Setting Database Connection Parameters in default_master.properties

The preferred method for setting the database connection parameters is to configure the external.jdbcDriverClass, external.jdbcUrl, external.dbUsername and dbPassword properties in the default_master.properties file prior to installation or upgrade. As of JasperReports Server 5.6, the default configuration of the externalDataSource bean in sample-applicationContext-externalAuth-db-mt.xml uses context properties for the database connection properties:

<bean id="externalDataSource"
    class="org.springframework.jdbc.datasource.DriverManagerDataSource">
  <property name="driverClassName" value="${external.jdbc.driverClassName}"/>  
  <property name="url" value="${external.jdbc.url}"/>
  <property name="username" value="${external.jdbc.username}"/>
  <property name="password" value="${external.jdbc.password}"/>
</bean>

To configure these properties using default_master.properties, follow these steps:

1. Open default_master.properties in a text editor.
2. Locate the following properties and set them for your LDAP server as follows:
external.jdbcDriverClass property – The name of the JDBC driver class for your database. Make sure the driver jar library is available on the classpath; for example, you can place the jar in the lib directory of your application server or in the <js-webapp>/lib directory.
external.jdbcUrl property – The JDBC URL for your database server, including the hostname, port, and database you want to access.
external.dbUsername property – The username of your database administrator.
external.dbPassword property — The password of your database administrator.
3. At this time, you can optionally choose to encrypt any of the LDAP connection parameters.

The following example shows the syntax of the properties in the default_master.properties file:

external.jdbcDriverClass=com.mysql.jdbc.Driver
external.jdbcUrl=jdbc:mysql://127.0.0.1:3306/external_sso_test
external.dbUsername=username
external.dbPassword=password

To encrypt the password property, you would also set the following:

encrypt=true
propsToEncrypt=dbPassword,external.dbPassword

See the JasperReports Server Administrator Guide for more information on encrypting passwords using buildomatic.

Setting Database Connection Parameters Manually

To set the connection parameters for the external database server directly in the application context file, configure the externalDataSource helper bean as follows:

If you configured your database connection during JasperReports Server installation, do not set the parameters using externalDataSource. You can verify whether the parameters are set by looking at the default_master.properties file.

1. In sample-applicationContext-externalAuth-db-mt.xml, locate the externalDataSource bean.
2. Specify the following information:
driverClassName property – The name of the JDBC driver class for your database. Make sure the driver jar library is available on the classpath; for example, you can place the jar in the lib directory of your application server or in the <js-webapp>/lib directory.
url property – The JDBC URL for your database server, including the hostname, port, and database you want to access.
username property – The username of your database administrator.
password property – The password of your database administrator.

The following is an example of the connection information for a MySQL database:

<bean id="externalDataSource" 
      class="org.springframework.jdbc.datasource.DriverManagerDataSource">
  <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
  <property name="url" value="jdbc:mysql://127.0.0.1:3306/external_sso_test"/>
  <property name="username" value="username"/>
  <property name="password" value="password"/>
</bean>
Feedback
randomness