Set Ofbiz using database PostgreSQL


Here is a quickstep to set OfBiz running using PostgreqSQL

1. Install PostgreSQL Driver
Download http://jdbc.postgresql.org/download/postgresql-9.3-1102.jdbc4.jar and put it on “ofbiz\framework\entity\lib\jdbc”

2. Setup new account and database
In Pgadmin, right click on “Login Role” and create a new account “ofbiz” with password “ofbiz”.
Also create database called “ofbiz” and the owner is “ofbiz”. Make sure it’s have write permission.

3. Edit configuration
Edit “ofbiz\framework\entity\config” and edit delegator name “default”. Change it using “localpostnew” instead of “localhsql”. You can replace with the current configuration with below:

1
2
3
4
5
6
7
8
9
10
11
    <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="localpostnew"/>
        <group-map group-name="org.ofbiz.olap" datasource-name="localderbyolap"/>
        <group-map group-name="org.ofbiz.tenant" datasource-name="localderbytenant"/>
        <!– <group-map group-name="org.ofbiz" datasource-name="localmysql"/>
        <group-map group-name="org.ofbiz.olap" datasource-name="localmysqlolap"/>
        <group-map group-name="org.ofbiz.tenant" datasource-name="localmysqltenant"/>  –>
        <!– <group-map group-name="org.ofbiz" datasource-name="localpostnew"/>
        <group-map group-name="org.ofbiz.olap" datasource-name="localpostolap"/>
        <group-map group-name="org.ofbiz.tenant" datasource-name="localposttenant"/> –>
    </delegator>

Next step, we need to configure the PostgreSQL connection, here is my example :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<datasource name="localpostgres"
            helper-class="org.ofbiz.entity.datasource.GenericHelperDAO"
            schema-name="public"
            field-type-name="postgres"
            check-on-start="true"
            add-missing-on-start="true"
            use-fk-initially-deferred="false"
            alias-view-columns="false"
            join-style="ansi"
            use-binary-type-for-blob="true"
            use-order-by-nulls="true">
            <!– use this attribute to make the EntityListIterator more effective for pgjdbc 7.5devel and later:
                result-fetch-size="50"
            –>
        <read-data reader-name="tenant"/>
        <read-data reader-name="seed"/>
        <read-data reader-name="seed-initial"/>
        <read-data reader-name="demo"/>
        <read-data reader-name="ext"/>
        <read-data reader-name="ext-test"/>
        <read-data reader-name="ext-demo"/>
        <inline-jdbc
                jdbc-driver="org.postgresql.Driver"
                jdbc-uri="jdbc:postgresql://127.0.0.1:5432/ofbiz"
                jdbc-username="ofbiz"
                jdbc-password="ofbiz"
                isolation-level="ReadCommitted"
                pool-minsize="2"
                pool-maxsize="250"
                time-between-eviction-runs-millis="600000"/><!– Be warned that at this date (2009-09-20) the max_connections parameters in postgresql.conf
                is set by default to 100 by the initdb process see http://www.postgresql.org/docs/8.4/static/runtime-config-connection.html#GUC-MAX-CONNECTIONS–>

        <!– <jndi-jdbc jndi-server-name="default" jndi-name="java:comp/env/jdbc/localpostgres" isolation-level="ReadCommitted"/>–>
        <!– <jndi-jdbc jndi-server-name="default" jndi-name="comp/env/jdbc/xa/localpostgres" isolation-level="ReadCommitted"/> –> <!– Orion Style JNDI name –>
        <!– <jndi-jdbc jndi-server-name="localweblogic" jndi-name="PostgresDataSource"/> –> <!– Weblogic Style JNDI name –>
        <!– <jndi-jdbc jndi-server-name="default" jndi-name="jdbc/localpostgres" isolation-level="ReadCommitted"/> –> <!– JRun4 Style JNDI name –>
        <!– <tyrex-dataSource dataSource-name="localpostgres" isolation-level="ReadCommitted"/> –>
    </datasource>

    <!– use localpostnew for NEW installations (don’t switch from localpostgres) and for PostgreSQL
     at or above 8.1 (for more information see the comment in the fieldtype file "fieldtypepostnew") –>

    <datasource name="localpostnew"
        helper-class="org.ofbiz.entity.datasource.GenericHelperDAO"
        schema-name="public"
        field-type-name="postnew"
        check-on-start="true"
        add-missing-on-start="true"
        use-fk-initially-deferred="false"
        alias-view-columns="false"
        join-style="ansi"
        result-fetch-size="50"
        use-binary-type-for-blob="true"
        use-order-by-nulls="true">
        <read-data reader-name="tenant"/>
        <read-data reader-name="seed"/>
        <read-data reader-name="seed-initial"/>
        <read-data reader-name="demo"/>
        <read-data reader-name="ext"/>
        <read-data reader-name="ext-test"/>
        <read-data reader-name="ext-demo"/>
        <inline-jdbc
            jdbc-driver="org.postgresql.Driver"
            jdbc-uri="jdbc:postgresql://127.0.0.1:5432/ofbiz"
            jdbc-username="ofbiz"
            jdbc-password="ofbiz"
            isolation-level="ReadCommitted"
            pool-minsize="2"
            pool-maxsize="250"
            time-between-eviction-runs-millis="600000"/><!– Be warned that at this date (2009-09-20) the max_connections parameters in postgresql.conf
                is set by default to 100 by the initdb process see http://www.postgresql.org/docs/8.4/static/runtime-config-connection.html#GUC-MAX-CONNECTIONS–>
       
        <!– <jndi-jdbc jndi-server-name="default" jndi-name="java:comp/env/jdbc/localpostgres" isolation-level="ReadCommitted"/>–>
        <!– <jndi-jdbc jndi-server-name="default" jndi-name="comp/env/jdbc/xa/localpostgres" isolation-level="ReadCommitted"/> –> <!– Orion Style JNDI name –>
        <!– <jndi-jdbc jndi-server-name="localweblogic" jndi-name="PostgresDataSource"/> –> <!– Weblogic Style JNDI name –>
        <!– <jndi-jdbc jndi-server-name="default" jndi-name="jdbc/localpostgres" isolation-level="ReadCommitted"/> –> <!– JRun4 Style JNDI name –>
        <!– <tyrex-dataSource dataSource-name="localpostgres" isolation-level="ReadCommitted"/> –>
    </datasource>

Last step, we just execute “ant load-demo”


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.