res-write-db

The res-write-db Ant task adds a RuleApp archive to the database persistence layer of Rule Execution Server. This task does not notify any other Rule Execution Server component.

When you deploy a RuleApp with a merging policy at the ruleset level, the RuleApp that already exists in the Rule Execution Server is updated with the deployed RuleApp (description, display name, properties). If you update this RuleApp by using the Rule Execution Server console, all modifications are lost at the next deployment that applies a merging policy at the ruleset level.

res-write-db element attributes 

The following table describes the res-write-db element attributes and specifies whether they are mandatory or optional.

Table 1. res-write-db element attributes 
Element attribute Description Mandatory/optional
credentialsfile

A file that contains the userid and password, encrypted the first time the attribute is used. If you set this attribute, do not use the userid and password attributes.

A credentials file is a text file that sets two properties: username and password.

Optional
driver The JDBC driver class name for the database. Mandatory
failonerror If you set this attribute to false, a warning message is logged when an error occurs, but the build process is not stopped.

Optional

The default value is true.

file The path of the RuleApp archive to write. Mandatory
mergingpolicy

The server uses the merge policy to process the RuleApp archive.

This attribute can take the following values:
  • ADD_AT_END_MERGING_POLICY: The existing RuleApp is not modified and the version of the new RuleApp is incremented to avoid a conflict. For example, if the RuleApp /MyRuleApp/1.0 already exists and you try to import a RuleApp archive that contains a RuleApp/MyRuleApp/1.0, the existing RuleApp is not modified and the new RuleApp is added with version number 2.0.
  • REPLACE_MERGING_POLICY: The existing RuleApp is replaced by the new RuleApp. With this policy, the versioningPolicy attribute is not used.
  • ADD_AT_END_RULESET_MERGING_POLICY: The existing ruleset is not modified and the version of the new ruleset is incremented to avoid a conflict.
  • REPLACE_RULESET_MERGING_POLICY: The existing ruleset is replaced by the new ruleset. With this policy, the versioningPolicy attribute is not used.

Optional.

The default value is ADD_AT_END_RULESET_MERGING_POLICY.

password The user password for the database. If you set this attribute, do not use the credentialsfile attribute. Mandatory
url The JDBC URL for the database. Mandatory
userid The user ID for the database. If you set this attribute, do not use the credentialsfile attribute. Mandatory
versioningpolicy

The server uses the version policy to process the RuleApp archive.

This attribute can take the following values:
  • MAJOR_VERSION_POLICY
  • MINOR_VERSION_POLICY

Optional.

The default value is MINOR_VERSION_POLICY.

resourceVersioningPolicy

The server uses the version policy to process the resource in the RuleApp archive.

This attribute can take the following values:
  • MAJOR_VERSION_POLICY
  • MINOR_VERSION_POLICY

Optional.

The default value is MAJOR_VERSION_POLICY.

libraryVersioningPolicy

The server uses the version policy to process the library in the RuleApp archive.

This attribute can take the following values:
  • MAJOR_VERSION_POLICY
  • MINOR_VERSION_POLICY

Optional.

The default value is MINOR_VERSION_POLICY.

classpath subelement

This class path must contain the JDBC driver classes. Wherever you must specify path-like values, you can use a nested element in the following form:
<classpath>
   <pathelement path="${classpath}"/>
   <pathelement location="lib/"/>
</classpath>

Example: RuleApp creation with no encryption

The following code sample shows how to run the res-write-db task by using the element attributes:
<target name="write-archive-to-db">
    <res-write-db driver="com.ibm.db2.jcc.DB2Driver"
        url="jdbc:db2://localhost:50000/DB2_8RES"
        userid="res"
        password="mypassword"
        mergingpolicy="ADD_AT_END_MERGING_POLICY"
        versioningpolicy="MAJOR_VERSION_POLICY"
        resourceVersioningPolicy="MAJOR_VERSION_POLICY"
        libraryVersioningPolicy="MINOR_VERSION_POLICY">
        <classpath>
            <pathelement location="db2jcc.jar"/>
            <pathelement location="db2jcc_license_cu.jar"/>
        </classpath>
    </res-write-db>
</target>

Example: Encrypted RuleApp creation

You can also run an encrypted res-write-db task by using the credentialsfile attribute. Replace the following attributes:
userid="res" password="mypassword"
with this attribute:
credentialsfile="mypasswordfile"
The credentials file is a text file that sets the following values:
username=res
password=mypassword
The file must comply with the Java™ format for property files. For more information, see the Java documentation External link opens a new window or tab. After the first execution of the res-deploy Ant task, the contents are encrypted. For example:
username={AES}6ee3l4NrmD3p8QTViSszow\=\=
password={AES}6ee3l4NrmD3p8QTViSszow\=\=

With encryption, the userid and password values are never displayed in plain text in traces during RuleApp deployment.