Search code examples
sql-serverrestcamunda

Camunda: Configure/setup MS SQL server database for rest api


By default, camunda rest api uses H2 database. I'm unable to locate the file where I can configure the rest api to use Microsoft SQL Server.

Apologies for not being much clear as I am new to camunda.


Solution

  • You can find information's about configure the JDBC connections in the Camunda installation Guide.

    For Example for Tomcat (you have to simply edit the driverClassName, url and the credentials).

    To configure a JDBC Resource you have to edit the file $TOMCAT_HOME/conf/server.xml. This could look like the following example for an H2 database:

    <Server>
      ...
      <GlobalNamingResources>
        ...
        <Resource name="jdbc/ProcessEngine"
                  auth="Container"
                  type="javax.sql.DataSource"
                  factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
                  uniqueResourceName="process-engine"
                  driverClassName="org.h2.Driver"
                  url="jdbc:h2:./camunda-h2-dbs/process-engine;MVCC=TRUE;TRACE_LEVEL_FILE=0"
                  username="sa"
                  password=""
                  maxActive="20"
                  minIdle="5" />
      </GlobalNamingResources>
    </Server>
    

    For JBoss or Wildfly you have to edit the standalone/configuration/standalone.xml:

    Add a datasource and driver tag, which could like the following, to the datasources.

    <datasource jta="true" enabled="true" use-java-context="true" use-ccm="true"
                    jndi-name="java:jboss/datasources/ProcessEngine"
                    pool-name="ProcessEngine">
        <connection-url>jdbc:sqlserver://SERVER_NAME:SERVER_PORT;databaseName=DB_NAME</connection-url>
        <driver>sqlserver2008</driver>
        <security>
            <user-name>USERNAME</user-name>
            <password>PASSWORD</password>
        </security>
        <pool>
            <min-pool-size>5</min-pool-size>
            <max-pool-size>50</max-pool-size>
            <prefill>false</prefill>
            <use-strict-min>false</use-strict-min>
            <flush-strategy>FailingConnectionOnly</flush-strategy>
        </pool>
        <validation>
            <valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.mssql.MSSQLValidConnectionChecker"></valid-connection-checker>
        </validation>
    </datasource>
    <drivers>
        <driver name="sqlserver2008" module="com.microsoft">
            <driver-class>com.microsoft.sqlserver.jdbc.SQLServerDriver</driver-class>
        </driver>
    </drivers>