Customize Liberty database connection with JDBC properties
We 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.
To customize the database connection, we 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 the application server data source installed by configureapplicationserver and installworklightadmin.
We 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.
- From the Sample configuration files, select the file configure-liberty-db2.xml, and copy it to the working directory.
- Review the Properties for the IBM Data Server Driver for JDBC and SQLJ in the DB2 for Linux UNIX and Windows user documentation.
- Edit the Ant file to add the relevant JDBC properties in configuredatabase, configureapplicationserver, and installworklightadmin.
<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>
Parent topic: Reference