How can make Kie-server to use external H2 database?

108 Views Asked by At

I have h2 database and I want Kie-server to connect to that database. Can someone help me to make it work. Following is the configuration I have done:

 <subsystem xmlns="urn:jboss:domain:datasources:6.0">
            <datasources>
                <datasource jndi-name="java:jboss/datasources/ExampleDS" pool-name="ExampleDS" enabled="true" use-java-context="true" statistics-enabled="${wildfly.datasources.statistics-enabled:${wildfly.statistics-enabled:false}}">
                    <connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE</connection-url>
                    <driver>h2</driver>
                    <security>
                        <user-name>sa</user-name>
                        <password>sa</password>
                    </security>
                </datasource>
                <xa-datasource jndi-name="java:jboss/datasources/jBPMDS" pool-name="jBPMXADS" enabled="true">
                    <xa-datasource-property name="URL">
                        jdbc:h2:tcp://my-h2/jbpm-db
                    </xa-datasource-property>
                    <xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
                    <driver>h2</driver>
                    <security>
                        <user-name>sa</user-name>
                        <password>sa</password>
                    </security>
                </xa-datasource>
                <drivers>
                    <driver name="h2" module="com.h2database.h2">
                        <xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
                    </driver>
                </drivers>
            </datasources>
1

There are 1 best solutions below

0
Abhijit Humbe On

Bydefault kie-server configured to use H2 DB. If you want to change the datasource used by kie-server then use below system-property:

-Dorg.kie.server.persistence.ds=java:jboss/datasources/jBPMDS

For now you are using H2 DB so you dont need to define dialect but in case you want to use different DB(ex. Oracle, Mysql) then you need to define dialect using below system-property

org.kie.server.persistence.dialect=org.hibernate.dialect.MySQL5InnoDBDialect