How to set Postgress as a Default Database for Apache Ofbiz

Posted By : Amit Kumar Gupta | 29-Jun-2017

Apache Ofbiz is a open souce application which is used for automation of business operation that consist of framework component and business application for CRM(Customer Realtionship Management), ERP(Enterprise Resource Planning), E-Commerce, MRP(Manufacturing Resource Planning), SCM(Supply Cahin Management). It handles all the business process like manufacturing of product, Create customer order,  create invoice of the order, product management etc. We can customize the apache ofbiz according to our business process. Latest Apache Ofbiz version many changes occur and added many more features. Default installation Ofbiz guide have derby database as default database. Derby database is Relational Database Management System developed by Apache that can be embedded in java programs. Derby database is used for small amount of data. For using large amount of data we use mysql, postgres, NoSql, MongoDB, Oracle SQL etc as a default database in Apache Ofbiz. In this blog we will describe how to set  postgres as a default database in Apache ofbiz. Postgres is open-source and porwerful relational database system.

1. Download the postgres and create 3 database in postgres(i.e. ofbiz, ofbizolap, ofbiztenant)

HTML part--

2. Edit this file: framework/entity/config/entityengine.xml.
	Step i) Ofbiz use Derby as default database. Change the default datasource-name postgress.
	Ex-    
        <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.apache.ofbiz" datasource-name="localpostgres"/>
        <group-map group-name="org.apache.ofbiz.olap" datasource-name="localpostolap"/>
        <group-map group-name="org.apache.ofbiz.tenant" datasource-name="localposttenant"/>
        </delegator>      
    	

	Step ii) Ofbiz already defined 3 connector for postgress : localpostgres, localpostolap and localposttenant. Search these 3 connector 		name in entityengine.xml.
	Step iii) Edit them for your database settings.
	Ex-
	jdbc-uri="jdbc:postgresql://127.0.0.1:5432/ofbiz" <--This is database name-->
        jdbc-username="ofbiz"  <--This is username-->
        jdbc-password="ofbiz"  <--This is password-->

3. Create the ofbiz plugin

	./gradlew createPlugin -PpluginId=PostgressDemo

4. And add gradle dependency of postgres in PostgresDemo plugin.

	dependencies {    
	      pluginLibsRuntime 'postgresql:postgresql:9.0-801.jdbc4' 
	}
	

5.After that Start command for load default data.

	./gradlew loadDefault
 

About Author

Author Image
Amit Kumar Gupta

Amit is a bright Web App Developer, and has good knowledge of Java,Machine Learning, Python, Algorithm. His hobbies are playing badminton and reading novel.

Request for Proposal

Name is required

Comment is required

Sending message..