Customizing the database connection with JDBC properties

You can customize the database connection with JDBC properties. This can be used to define the security (SSL) of the connection to the database server, timeouts, or JDBC traces.

About this task

To customize the database connection, you must add <property> elements to the database elements for the tasks configuredatabase, configureapplicationserver, and installworklightadmin. The JDBC properties are used by the Ant tasks when connecting to the database, and by the application server data source installed by configureapplicationserver and installworklightadmin.

You can find in the following procedure an example that defines the properties to set the command timeout for DB2® for the connection to the administration database.

Note: The steps for customization that are described in this page do not apply if you are using a Cloudant® database. For customizing Cloudant, see Property keys and values for Cloudant configuration and JNDI properties for Administration Services: IBM® Cloudant database.

Procedure

  1. From the Sample configuration files, select the file configure-liberty-db2.xml, and copy it to your working directory.
  2. Review the Properties for the IBM Data Server Driver for JDBC and SQLJ in the DB2 for Linux UNIX and Windows user documentation.
  3. Edit the Ant file to add the relevant JDBC properties in configuredatabase, configureapplicationserver, and intallworklightadmin.
    <target name="admdatabases">
      <configuredatabase kind="WorklightAdmin">
        <db2 database="${database.db2.wladmin.dbname}"
             server="${database.db2.host}"
             instance="${database.db2.instance}"
             user="${database.db2.wladmin.username}"
             port= "${database.db2.port}"
             schema = "${database.db2.wladmin.schema}"
             password="${database.db2.wladmin.password}">
    
          <property name="commandTimeout" value="10"/>
    
        </db2>
    
        (...)
    
    <target name="adminstall">
      <installworklightadmin>
        <console install="${wladmin.console.install}"/>
        <jmx/>
        <applicationserver>
          <websphereapplicationserver installdir="${appserver.was.installdir}"
                                      profile="${appserver.was.profile}">
            <server name="${appserver.was85liberty.serverInstance}"/>
          </websphereapplicationserver>
        </applicationserver>
        <user name="${wladmin.default.user}" 
              role="worklightadmin"
              password="${wladmin.default.user.initialpassword}"/>
        <database kind="WorklightAdmin">
          <db2 database="${database.db2.wladmin.dbname}"
               server="${database.db2.host}"
               user="${database.db2.wladmin.username}"
               port= "${database.db2.port}"
               schema = "${database.db2.wladmin.schema}"
               password="${database.db2.wladmin.password}">
    
            <property name="commandTimeout" value="10"/>
    
          </db2>
    
          (...)