Setting the Database Connection Parameters¶
You can configure your connection to the database in one of two ways:
- Configure the connection during installation of JasperReports Server by configuring the
external.jdbcDriverClass,external.jdbcUrl,external.dbUsername, and/orexternal.dbPasswordproperties before installation or upgrade. You can choose to encrypt any of the database connection parameters. This is the preferred method for setting the database connection parameters. See the JasperReports Server Security Guide for more information. - If you have a 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, can't 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 before installation or upgrade. In JasperReports Server 5.6 and later, 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="com.jaspersoft.jasperserver.api.security.
externalAuth.wrappers.spring.jdbc.JSDriverManagerDataSource">
<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:
-
Open default_master.properties in a text editor.
-
Locate and set the following properties for your LDAP server:
external.jdbcDriverClassproperty: 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.jdbcUrlproperty: The JDBC URL for your database server, including the hostname, port, and database you want to access.external.dbUsernameproperty: The username of your database administrator.external.dbPasswordproperty: The password of your database administrator.
-
You can 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, also set the following:
See the JasperReports Server Security Guide for more information on encrypting passwords using buildomatic.
Setting Database Connection Parameters Manually¶
Note
If you configured your database connection during JasperReports Server installation, don't set the parameters using externalDataSource. You can verify whether the parameters are set by looking at the default_master.properties file.
To set the connection parameters for the external database server directly in the application context file, configure the externalDataSource helper bean as follows:
- In sample-applicationContext-externalAuth-db-mt.xml, locate the
externalDataSourcebean. -
Specify the following information:
-
driverClassNameproperty: 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. urlproperty: The JDBC URL for your database server, including the hostname, port, and database you want to access.usernameproperty: The username of your database administrator.passwordproperty: The password of your database administrator.
The following is an example of the connection information for a MySQL database:
<bean id="externalDataSource" class="com.jaspersoft.jasperserver.api.security.
externalAuth.wrappers.spring.jdbc.JSDriverManagerDataSource">
<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>