Apache OFBiz

How to setup Mysql as Datasource for Apache OFBiz

Apache OFBiz support almost database(MySql, Postgres, Derby, Oracle, Sysbase,…). By default, OFBiz uses Embedded Derby as database. In this post, I will show you how to change(For example: MySql) to another database.

View main post: How to setup Mysql as Datasource for Apache OFBiz

Step 1: Open entityengine.xml file

Go to: OFBiz source directory -> framework -> entity -> config

This file have xml structure.

Step 2: Change data-source from Derby to Mysql

Find the following lines:(some first lines)

<delegator name=”default” entity-model-reader=”main” entity-group-reader=”main” entity-eca-reader=”main” distributed-cache-clear-enabled=”false”>
<group-map group-name=”org.ofbiz” datasource-name=”localderby”/>
<group-map group-name=”org.ofbiz.olap” datasource-name=”localderbyolap”/>
<group-map group-name=”org.ofbiz.tenant” datasource-name=”localderbytenant”/>
</delegator>

Change “datasource-name” to:

  • datasource-name=”localmysql”
  • datasource-name=”localmysqlolap”
  • datasource-name=”localmysqltenant”

OFBiz has three main databases:

  • group-name=”org.ofbiz”: For main database.
  • group-name=”org.ofbiz.olap”: For olap database.
  • group-name=”org.ofbiz.tenant”: For tenant database.

In the remaining part of files, you find three template data-source for mysql:

  • <datasource name=”localmysql”
  • <datasource name=”localmysqlolap”
  • <datasource name=”localmysqltenant”

In each tag, you have to change database’s address, database name, user-name and password to your database configurations. Change them in attribute:

  • jdbc-uri: database address and database’s name(red and blue color)
  • jdbc-username: database’s username(magenta color)
  • jdbc-password: database’s password(yellow color)

For example: 

jdbc-uri=”jdbc:mysql://127.0.0.1/ofbiz?autoReconnect=true”
jdbc-username=”ofbiz
jdbc-password=”ofbiz

Now, you can work with Apache OFBiz on Mysql database.

For more detail, visit this video: How to setup Mysql as Datasource for Apache OFBiz

Leave a comment