Switching Ofbiz 16.11.04 to Postgresql 9.6 on Windows 10

      1. Follow instruction from Ofbiz technical set up guide.
      2. Download 64 bit Postgresql.  This download will include a version of pgadmin.
      3. In the case pgadmin in step 2 not working, download pgadmin v4 by itself.  It only comes in 32 bits but it seems to work fine with the 64 bit Postgresql.
      4. Start postgresql by issuing postgresql -D ..\data in command prompt.  Do not run in admin mode.  The postgresql command is available under <installed directory>/bin if you have not put this in the path system variable.
      5. Invoke, in admin mode, pgadmin v4 .  A web page will show up to ask you to connect to postgresql v9.  Click on it then input the admin password you set up in step 2.  Note:  don’t run pgadmin through an admin shell.  Invoked it through file explorer or program tab.  It may take a few trys for pgadmin to make connection to the server.
      6. Modify <install directory>/apache-ofbiz-16.11.04\framework\entity\config\entityengine.xml.  Modify the datasource section and the delegator section from derby to postgresql.  Make sure the information for inline-jdbc connection string reflects your set up.
        The delegator section:
        <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"/>
        
        <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"/>
        
        <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"/>
        

        The datasource section for “localpostgres”, “localpostolap” and “localposttenant”
        The connection string to jdbc-uri is “jdbc:postgresql://<host ip>:<db port>/db name”
        localhost ip address is 127.0.0.1
        jdbc-username is whoever owns the database and have create table privilege

        jdbc-driver="org.postgresql.Driver"
        jdbc-uri="jdbc:postgresql://127.0.0.1:5432/ofbiz"
        jdbc-username="ofbiz"
        jdbc-password="ofbiz"
        isolation-level="ReadCommitted"
        
        jdbc-driver="org.postgresql.Driver"
        jdbc-uri="jdbc:postgresql://127.0.0.1:5432/ofbizolap"
        jdbc-username="ofbiz"
        jdbc-password="ofbiz"
        isolation-level="ReadCommitted"
        
        jdbc-driver="org.postgresql.Driver"
        jdbc-uri="jdbc:postgresql://127.0.0.1:5432/ofbiztenant"
        jdbc-username="ofbiz"
        jdbc-password="ofbiz"
        isolation-level="ReadCommitted"
        
      7. Inside file \apache-ofbiz-16.11.02\build.gradle , add this line:
        compile 'org.postgresql:postgresql:42.1.1'
      8. Start postgresql server (<install directory>/bin/postgres -D ..\data).  Create three databases in postgresql, ofbiz, ofbizolap and ofbiztenant.  Make sure the charset for the databases is utf-8.  Create user ofbiz who must have table creating privileges for all three databases.
      9. Run the following commands from ofbiz directory:
        • Command gradlew eclipse, generate metadata for Eclipse IDE from existing source code.
        • Command gradlew cleanAll, clean old artifact, build files.
        • Command gradlew loadDefault, load sample data into database.
        • Command gradlew ofbizDebug, run ofbiz in debug mode. You you don’t like debug model, use command gradlew ofbiz.
      10. If you run into database connection problems, it would be helpful to check the postgresql logs located in /data/pg_log