Monday, July 30, 2012

Activiti activiti-explorer connects to Oracle


Its' nice to have a working Activiti after downloading, but the default H2 database seems hard to switch to Oracle. The simplest way to do it is:

Copy the activiti-explorer to existing tomcat_home/webapps directory, then open activiti-explorer/WEB-INF/application-Context.xml

comment out the default connection:

     <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
     < property name="driverClassName" value="${jdbc.driver}" />
      < property name="url" value="${jdbc.url}" />
     < property name="username" value="${jdbc.username}" />
      < property name="password" value="${jdbc.password}" />
       < property name="defaultAutoCommit" value="false" />
   < /bean>
   
Copy the JNDI resource in your Tomcat server.xml:

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
       < property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" />
       < property name="url" value="jdbc:oracle:thin:@oratest.test1.com:1521:test1" />
       < property name="username" value="user" />
       < property name="password" value="passwd" />
      < property name="defaultAutoCommit" value="false" />
    < /bean>    
   
  Make sure the account you are using could create new tables in the Oracle database, because the first time you start activiti-explorer it will try to create all the tables.

Retart Tomcat, and now you are using Oracle instead of H2.

Or, instead of hard coding, change it in WEB-INF/classes/db.properties file. Original file:

db=h2
jdbc.driver=org.h2.Driver
jdbc.url=jdbc\:h2\:tcp\://localhost/activiti
jdbc.username=sa
jdbc.password=

change to:

db=oracle
jdbc.driver=oracle.jdbc.driver.OracleDriver
jdbc.url=jdbc:oracle:thin:@oratest.test1.com:1521:test1
jdbc.username=sa
jdbc.password=

No comments: