<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">
<div>
<table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
<tbody>
<tr>
<td>
<table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
<tbody>
<tr>
<td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
<h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
<!-- To have a header image/logo replace the name below with your img tag -->
<!-- Email clients will render the images when the message is read so any image -->
<!-- must be made available on a public server, so that all recipients can load the image. -->
<a href="http://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
</td>
</tr>
<tr>
<td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px; -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
Adding a Database Axis
</h3>
<span style="margin-bottom: 10px;">
modified by <a href="http://community.jboss.org/people/admin">Administrator Administrator</a> in <i>jBPM</i> - <a href="http://community.jboss.org/docs/DOC-12931">View the full document</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">
<div class="jive-rendered-content"><p><div class="toc" style="border: 1px dashed black; padding: 10px;"><ul><ul><ul><li>
<a class="jive-link-anchor-small" href="#Specify_Connection_Properties">Specify Connection Properties</a>
</li>
<li>
<a class="jive-link-anchor-small" href="#Provide_Data_Source">Provide Data Source</a>
</li>
<li>
<a class="jive-link-anchor-small" href="#Create_Maven_Profile">Create Maven Profile</a>
</li>
<li>
<a class="jive-link-anchor-small" href="#Fill_in_Connection_Parameters">Fill in Connection Parameters</a>
</li>
<li>
<a class="jive-link-anchor-small" href="#Specify_Connection_Properties_For_Update">Specify Connection Properties For Update</a>
</li>
<li>
<a class="jive-link-anchor-small" href="#List_Database_as_Installation_Choice">List Database as Installation Choice</a>
</li>
<li>
<a class="jive-link-anchor-small" href="#Set_Up_DBMS">Set Up DBMS</a>
</li>
<li>
<a class="jive-link-anchor-small" href="#Run_Test_Suite">Run Test Suite</a>
</li>
<li>
<a class="jive-link-anchor-small" href="#Add_Database_Axis_To_Hudson_Jobs">Add Database Axis To Hudson Jobs</a>
</li>
</ul></ul></ul></div></p><h3 id="Specify_Connection_Properties">Specify Connection Properties<br/></h3><p>Let's add a PostgreSQL axis.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>jBPM3 already generates the DDL scripts for many databases. Edit <a class="jive-link-external-small" href="http://anonsvn.jboss.org/repos/jbpm/jbpm3/trunk/modules/core/src/main/resources/hibernate.properties.postgresql.xml">hibernate.properties.postgresql.xml</a></p><pre class="jive-pre"><code class="jive-code jive-xml"><span class="jive-xml-comment"><!-- hibernate dialect -->
<span class="jive-xml-tag"><property name="hibernate.dialect"></span>org.hibernate.dialect.PostgreSQLDialect<span class="jive-xml-tag"></property></span>
<!-- JDBC connection properties (begin) -->
<span class="jive-xml-tag"><property name="hibernate.connection.driver_class"></span>org.postgresql.Driver<span class="jive-xml-tag"></property></span>
<span class="jive-xml-tag"><property name="hibernate.connection.url"></span>${jdbc.postgresql.url}<span class="jive-xml-tag"></property></span>
<span class="jive-xml-tag"><property name="hibernate.connection.username"></span>${jdbc.postgresql.username}<span class="jive-xml-tag"></property></span>
<span class="jive-xml-tag"><property name="hibernate.connection.password"></span>${jdbc.postgresql.password}<span class="jive-xml-tag"></property></span>
<!-- JDBC connection properties (end) --></span>
</code></pre><h3 id="Provide_Data_Source">Provide Data Source</h3><p>Create jbpm-postgresql-ds.xml in <a class="jive-link-external-small" href="http://anonsvn.jboss.org/repos/jbpm/jbpm3/trunk/modules/jpdl/core/src/main/resources">modules/core/src/main/resources</a>. Use <a class="jive-link-wiki-small" href="http://community.jboss.org/docs/DOC-9328">ConfigDataSources</a> as a reference.</p><pre class="jive-pre"><code class="jive-code jive-xml"><span class="jive-xml-tag"><xa-datasource></span>
  <span class="jive-xml-tag"><jndi-name></span>JbpmDS<span class="jive-xml-tag"></jndi-name></span>
  <span class="jive-xml-tag"><xa-datasource-class></span>org.postgresql.xa.PGXADataSource<span class="jive-xml-tag"></xa-datasource-class></span>
  <span class="jive-xml-tag"><xa-datasource-property name="ServerName"></span>${jdbc.postgresql.server}<span class="jive-xml-tag"></xa-datasource-property></span>
  <span class="jive-xml-tag"><xa-datasource-property name="PortNumber"></span>${jdbc.postgresql.port}<span class="jive-xml-tag"></xa-datasource-property></span>
  <span class="jive-xml-tag"><xa-datasource-property name="DatabaseName"></span>${jdbc.postgresql.database}<span class="jive-xml-tag"></xa-datasource-property></span>
  <span class="jive-xml-tag"><user-name></span>${jdbc.postgresql.username}<span class="jive-xml-tag"></user-name></span>
  <span class="jive-xml-tag"><password></span>${jdbc.postgresql.password}<span class="jive-xml-tag"></password></span>
  <span class="jive-xml-comment"><!-- disable transaction interleaving -->
  <span class="jive-xml-tag"><track-connection-by-tx /></span>
  <!-- corresponding type-mapping in conf/standardjbosscmp-jdbc.xml --></span>
  <span class="jive-xml-tag"><metadata></span>
    <span class="jive-xml-tag"><type-mapping></span>PostgreSQL 8.0<span class="jive-xml-tag"></type-mapping></span>
  <span class="jive-xml-tag"></metadata></span>
<span class="jive-xml-tag"></xa-datasource></span>
</code></pre><h3 id="Create_Maven_Profile">Create Maven Profile</h3><p>In the root POM add a profile that contains the dependency on the JDBC driver</p><pre class="jive-pre"><code class="jive-code jive-xml"><span class="jive-xml-tag"><dependencyManagement></span>
  <span class="jive-xml-tag"><dependencies></span>
    <span class="jive-xml-tag"><dependency></span>
      <span class="jive-xml-tag"><groupId></span>postgresql<span class="jive-xml-tag"></groupId></span>
      <span class="jive-xml-tag"><artifactId></span>postgresql<span class="jive-xml-tag"></artifactId></span>
      <span class="jive-xml-tag"><version></span>${postgresql.version}<span class="jive-xml-tag"></version></span>
    <span class="jive-xml-tag"></dependency></span>
  <span class="jive-xml-tag"></dependencies></span>
<span class="jive-xml-tag"></dependencyManagement></span>
<span class="jive-xml-tag"><profiles></span>
  <span class="jive-xml-tag"><profile></span>
    <span class="jive-xml-tag"><id></span>postgresql<span class="jive-xml-tag"></id></span>
    <span class="jive-xml-tag"><activation></span>
      <span class="jive-xml-tag"><property></span>
        <span class="jive-xml-tag"><name></span>database<span class="jive-xml-tag"></name></span>
        <span class="jive-xml-tag"><value></span>postgresql<span class="jive-xml-tag"></value></span>
      <span class="jive-xml-tag"></property></span>
    <span class="jive-xml-tag"></activation></span>
    <span class="jive-xml-tag"><dependencies></span>
      <span class="jive-xml-tag"><dependency></span>
        <span class="jive-xml-tag"><groupId></span>postgresql<span class="jive-xml-tag"></groupId></span>
        <span class="jive-xml-tag"><artifactId></span>postgresql<span class="jive-xml-tag"></artifactId></span>
        <span class="jive-xml-tag"><scope></span>test<span class="jive-xml-tag"></scope></span>
      <span class="jive-xml-tag"></dependency></span>
    <span class="jive-xml-tag"></dependencies></span>
  <span class="jive-xml-tag"></profile></span>
<span class="jive-xml-tag"></profiles></span>
</code></pre><h3 id="Fill_in_Connection_Parameters">Fill in Connection Parameters</h3><p>Specify the connection property values that correspond to the target environment in the following locations.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><table><tbody><tr><th style=";">Environment</th><th style=";">File</th><th style=";">Location</th></tr><tr><td style=";">jBPM Dev</td><td style=";">profiles.xml</td><td style=";">${basedir}</td></tr><tr><td style=";">Local Dev <strong>*</strong></td><td style=";">settings.xml</td><td style=";">${user.home}/.m2</td></tr><tr><td style=";">Local QA</td><td style=";">profiles.xml.local.qa</td><td style=";">${basedir}/hudson</td></tr><tr><td style=";">Red Hat QA</td><td style=";">profiles.xml.redhat.qa</td><td style=";">${basedir}/hudson</td></tr></tbody></table><p><strong>*</strong> Useful if you have multiple jBPM branches checked out</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>For a local PostgreSQL installation the property values would look like this:</p><pre class="jive-pre"><code class="jive-code jive-xml"><span class="jive-xml-tag"><properties></span>
  <span class="jive-xml-tag"><jdbc.postgresql.server></span>localhost<span class="jive-xml-tag"></jdbc.postgresql.server></span>
  <span class="jive-xml-tag"><jdbc.postgresql.port></span>5432<span class="jive-xml-tag"></jdbc.postgresql.port></span>
  <span class="jive-xml-tag"><jdbc.postgresql.database></span>jbpmtest<span class="jive-xml-tag"></jdbc.postgresql.database></span>
  <span class="jive-xml-tag"><jdbc.postgresql.url></span>jdbc:postgresql://${jdbc.postgresql.server}:${jdbc.postgresql.port}/${jdbc.postgresql.database}<span class="jive-xml-tag"></jdbc.postgresql.url></span>
  <span class="jive-xml-tag"><jdbc.postgresql.username></span>jbpmtest<span class="jive-xml-tag"></jdbc.postgresql.username></span>
  <span class="jive-xml-tag"><jdbc.postgresql.password></span><span class="jive-xml-tag"></jdbc.postgresql.password></span>
<span class="jive-xml-tag"></properties></span>
</code></pre><h3 id="Specify_Connection_Properties_For_Update">Specify Connection Properties For Update</h3><p>Generating the DB schema update script requires access to an alternate database hosting the schema from a previous version. Create postgresql.properties in <a class="jive-link-external-small" href="http://anonsvn.jboss.org/repos/jbpm/jbpm3/trunk/modules/jpdl/db/src/main/resources">modules/db/src/main/resources</a>.</p><pre class="jive-pre"><code class="jive-code">hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
#
# This uses the jbpm322 database schema as reference for the SchemaUpdate task
#
hibernate.connection.driver_class=org.postgresql.Driver
hibernate.connection.url=jdbc:postgresql://${jdbc.postgresql.server}:${jdbc.postgresql.port}/jbpm322
hibernate.connection.username=${jdbc.postgresql.username}
hibernate.connection.password=${jdbc.postgresql.password}
</code></pre><p><a class="jive-link-external-small" href="http://anonsvn.jboss.org/repos/jbpm/jbpm3/trunk/modules/db/scripts/antrun-jbpmschema.xml">antrun-jbpmschema.xml</a></p><pre class="jive-pre"><code class="jive-code jive-xml"><span class="jive-xml-tag"><target name="update-schema" depends="setup-schema" description="Generate jBPM Database Update Scripts"></span>
  <span class="jive-xml-tag"><jbpmschema output="${scriptsdir}/jbpm.jpdl.postgresql.update322.sql" config="hibernate.cfg.postgresql.xml" properties="postgresql.properties" action="update" delimiter=";"/></span>
<span class="jive-xml-tag"></target></span>
</code></pre><h3 id="List_Database_as_Installation_Choice">List Database as Installation Choice<br/></h3><p><a class="jive-link-external-small" href="http://anonsvn.jboss.org/repos/jbpm/jbpm3/trunk/modules/distribution/src/main/resources/installer/install-definition.xml">install-definition.xml</a></p><pre class="jive-pre"><code class="jive-code jive-xml"><span class="jive-xml-tag"><conditions></span>
  <span class="jive-xml-tag"><condition type="variable" id="isPostgreSQL"></span>
    <span class="jive-xml-tag"><name></span>dbSelection<span class="jive-xml-tag"></name></span>
    <span class="jive-xml-tag"><value></span>postgresql<span class="jive-xml-tag"></value></span>
  <span class="jive-xml-tag"></condition></span>
<span class="jive-xml-tag"></conditions></span>
<span class="jive-xml-tag"><packs></span>
  <span class="jive-xml-comment"><!--
  ********************************
  *   JBoss Integration          *
  ********************************
  -->
  <span class="jive-xml-tag"><pack name="jBPM3 JBoss Integration" required="no" preselected="yes"></span>
    <!-- Database configs to docs/examples/jbpm -->
    <span class="jive-xml-tag"><fileset dir="@{deploy.artifacts.dir}/resources/jbpm-jpdl-config" targetdir="${jbossInstallPath}/docs/examples/jbpm" override="true"></span>
      <span class="jive-xml-tag"><include name="hibernate.cfg.postgresql.xml"/></span>
      <span class="jive-xml-tag"><include name="jbpm-postgresql-ds.xml"/></span>
    <span class="jive-xml-tag"></fileset></span>
    <!-- Database PostgreSQL --></span>
    <span class="jive-xml-tag"><file src="@{deploy.artifacts.dir}/resources/jbpm-jpdl-config/jbpm-postgresql-ds.xml" targetdir="${jbossInstallPath}/server/${jbossTargetServer}/deploy/jbpm"  condition="isPostgreSQL"/></span>
    <span class="jive-xml-tag"><singlefile src="@{deploy.artifacts.dir}/resources/jbpm-jpdl-config/hibernate.cfg.postgresql.xml" condition="isPostgreSQL"
      target="${jbossInstallPath}/server/${jbossTargetServer}/deploy/jbpm/jbpm-service.sar/hibernate.cfg.xml" /></span>
    <span class="jive-xml-tag"><fileset dir="@{deploy.artifacts.dir}/lib" targetdir="${jbossInstallPath}/server/${jbossTargetServer}/deploy/jbpm/jbpm-service.sar" override="true" condition="isPostgreSQL"></span>
      <span class="jive-xml-tag"><include name="postgresql.jar" /></span>
    <span class="jive-xml-tag"></fileset></span>
  <span class="jive-xml-tag"></pack></span>
<span class="jive-xml-tag"></packs></span>
</code></pre><p><a class="jive-link-external-small" href="http://anonsvn.jboss.org/repos/jbpm/jbpm3/trunk/modules/distribution/src/main/resources/installer/user-input-spec.xml">user-input-spec.xml</a></p><pre class="jive-pre"><code class="jive-code jive-xml"><span class="jive-xml-tag"><panel order="2"></span>
  <span class="jive-xml-tag"><createForPack name="jBPM3 JBoss Integration" /></span>
  <span class="jive-xml-tag"><field type="radio" variable="dbSelection"></span>
    <span class="jive-xml-tag"><spec></span>
      <span class="jive-xml-tag"><choice txt="PostgreSQL" value="postgresql"/></span>
    <span class="jive-xml-tag"></spec></span>
  <span class="jive-xml-tag"></field></span>
<span class="jive-xml-tag"></panel></span>
</code></pre><p><a class="jive-link-external-small" href="http://anonsvn.jboss.org/repos/jbpm/jbpm3/trunk/modules/distribution/scripts/antrun-installer.xml">antrun-installer.xml</a></p><pre class="jive-pre"><code class="jive-code jive-xml"><span class="jive-xml-tag"><target name="configure" depends="init"></span>
  <span class="jive-xml-tag"><property name="postgresql.cfg.xml" value="${deploy.artifacts.resources}/jbpm-jpdl-config/hibernate.cfg.postgresql.xml"/></span>
  <span class="jive-xml-tag"><macro-disable file="${postgresql.cfg.xml}" section="JDBC connection properties"/></span>
  <span class="jive-xml-tag"><macro-disable file="${postgresql.cfg.xml}" section="Automatic schema creation"/></span>
  <span class="jive-xml-tag"><macro-enable file="${postgresql.cfg.xml}" section="DataSource properties"/></span>
  <span class="jive-xml-tag"><macro-enable file="${postgresql.cfg.xml}" section="JTA transaction properties"/></span>
<span class="jive-xml-tag"></target></span>
</code></pre><h3 id="Set_Up_DBMS">Set Up DBMS<br/></h3><p>See <a class="jive-link-wiki-small" href="http://community.jboss.org/docs/DOC-13270">Install PostgreSQL on Fedora</a></p><h3 id="Run_Test_Suite">Run Test Suite<br/></h3><p>Finally you should be able to run the jBPM3 tests against PostgreSQL using the <strong>-Ddatabase</strong> option</p><pre class="jive-pre"><code class="jive-code">[tdiesler@tddell core]$ mvn -Ddatabase=postgresql -Dtest=EndTasksDbTest test
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building JBoss jBPM - jPDL Core
[INFO]    task-segment: [test]
[INFO] ------------------------------------------------------------------------
[INFO] [antrun:run {execution: default}]
[INFO] Executing tasks
check-database:
     [echo] Concat hibernate.cfg.xml using hibernate.properties.postgresql.xml
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running org.jbpm.taskmgmt.exe.EndTasksDbTest
Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 25.799 sec
Results :
Tests run: 4, Failures: 0, Errors: 0, Skipped: 0
</code></pre><h3 id="Add_Database_Axis_To_Hudson_Jobs">Add Database Axis To Hudson Jobs</h3><p>When the Maven build is setup to use the database for testing, you simple need to add the axis to the Hudson config.</p><pre class="jive-pre"><code class="jive-code jive-xml"><span class="jive-xml-tag"><axis></span>
  <span class="jive-xml-tag"><name></span>database<span class="jive-xml-tag"></name></span>
  <span class="jive-xml-tag"><values></span>
    <span class="jive-xml-tag"><string></span>hsqldb<span class="jive-xml-tag"></string></span>
    <span class="jive-xml-tag"><string></span>mysql<span class="jive-xml-tag"></string></span>
    <span class="jive-xml-tag"><string></span>postgresql<span class="jive-xml-tag"></string></span>
  <span class="jive-xml-tag"></values></span>
<span class="jive-xml-tag"></axis></span>
</code></pre><p>This can also be done from the web interface.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Good Luck</p></div>
<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
<p style="margin: 0;">Comment by <a href="http://community.jboss.org/docs/DOC-12931">going to Community</a></p>
<p style="margin: 0;">Create a new document in jBPM at <a href="http://community.jboss.org/choose-container!input.jspa?contentType=102&containerType=14&container=2034">Community</a></p>
</div></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>