ILOG JRules User Guide > Deploying Rules > Reference > RuleApp Management Using Ant > res-write-db Task

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

The following Ant task code provides an example of how to run the res-write-db task using the element attributes:

<res-write-db driver="oracle.jdbc.driver.OracleDriver" 
               url="jdbc:oracle:oci:@//localhost:1521/default" 
               userid="bres" password="mypassword" file="myruleapp.jar">
   <classpath>
      <pathelement location="classes12.jar"/>
   </classpath>
</res-write-db>

You can also run an encrypted res-write-db task using the credentialsfile attribute.

To run an encrypted res-write-db task, replace the following attributes:

userid="bres" password="mypassword"

with the attribute:

credentialsfile="mypasswordfile"

where credentialsfile is a text file that contains:


 
username=bres 
password=mypassword  

The file must follow the Java property files format. For more information, see http://java.sun.com/j2se/1.4.2/docs/api/java/util/Properties.html#load(java.io.InputStream). After the first execution of the res-deploy ANT task, the contents are encrypted. For example:


 
username={DES}oLHZROlruWw\= 
password={DES}als58ekruWw\=  

With encryption, the userid and password never appear in plain text in traces during the RuleApp deployment operation.

The following table describes the res-write-db element attributes and specifies whether or not they are required elements.

Table 12 res-write-db Element Attributes 
Element Attribute 
Description 
Required 
file 
The path of the RuleApp archive to write. 
Yes 
userid 
The user ID for the database. 
Yes 
password 
The user password for the database. 
Yes 
credentialsfile 
A file containing the userid and password, encrypted when the attribute is first used. If this attribute is present, the userid and password attributes must not be used. 
No 
driver 
The JDBC driver class name for the database. 
Yes 
url 
The JDBC URL for the database. 
Yes 
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 the version 2.0.  
REPLACE_MERGING_POLICY: The existing RuleApp is replaced by the new RuleApp. With this policy, the argument versioningPolicy 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 argument versioningPolicy is not used.  
No, default value is ADD_AT_END_MERGING_POLICY 
versioningpolicy 
The server uses the versioning policy to process the RuleApp archive. This attribute can take the following values: 
MAJOR_VERSION_POLICY 
MINOR_VERSION_POLICY 
No, default value is MAJOR_VERSION_POLICY 
failonerror 
The default is set to true. If it is set to false, a warning message is logged when an error occurs, but the build is not stopped.  
No 

The classpath Subelement

This classpath should contain the JDBC driver classes. Wherever path-like values need to be specified, you can use a nested element. This takes the general form of:

<classpath>
   <pathelement path="${classpath}"/>
   <pathelement location="lib/"/>
</classpath>

Related Concepts

RuleApps and RuleApp Projects

Related Topics

Task Mappings
Rule Execution Server Tasks
res-jar Task
res-fetch Task
res-fetch-all Task
res-deploy
res-undeploy Task
res-write-file Task
res-delete-file Task
res-delete-db Task

Related Tasks

Deploying and Exporting RuleApps

Related Samples and Tutorials

Tutorial: RuleApp Management
How to Automate Ruleset Management
How to Migrate RuleApps

Related Reference

RuleApp Management Using MBeans Accessor API
http://ant.apache.org/