Out-of-the-box, OFBiz is integrated with the Apache Derby database system (http://db.apache.org/derby). While Derby is sufficient to handle OFBiz during software development, evaluation, and functional testing, it is not recommended for environments that experience high transaction volumes. In particular, it is not recommended for use in production environments.
Before configuring an external database, the following few steps have to be ensured:
Note: if you are not going to install the OFBiz schema and/or seed data on the remote database, but rather intend to use it as is, you will not need to create a database. You will need, however, to define entities for each remote database table you wish to access, and assign those entities to one or more entity groups.
~framework/entity/lib/jdbc
directory.For example, if you are using PostgreSQL version 8.3, download the postgresql-8.3-605.jdbc2.jar
driver from the PostgreSQL website (http://jdbc.postgresql.org/download.html).
To configure another external database, follow these few steps:
~framework/entity/config/entityengine.xml
entityengine.xml
file, configure the remote database's usage settings. A suggested method for doing this is to take an existing datasource
element entry and modify that to reflect the necessary settings for a remote database. There are examples provided for most of the commonly used databases.For example, to configure a remote PostgreSQL database with the name of myofbiz_db
, with a username ofbiz
and password of ofbiz
, edit the localpostnew
configuration entry as shown here:
<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"> <read-data reader-name="seed"/> <read-data reader-name="seed-initial"/> <read-data reader-name="demo"/> <read-data reader-name="ext"/> <inline-jdbc jdbc-driver="org.postgresql.Driver" jdbc-uri="jdbc:postgresql://127.0.0.1/myofbiz_db" jdbc-username="ofbiz" jdbc-password="ofbiz" isolation-level="ReadCommitted" pool-minsize="2" pool-maxsize="250"/> </datasource>
delegator
for this data source:<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"/> </delegator>
entityengine.xml
file. ant run-install
command.https://localhost:8443/webtools/control/entityref
) to search for your newly created entities, or a third-party tool designed to work with your specific database.The Entity Engine is configured using the entityengine.xml
file. Whenever OFBiz is restarted, the Entity Engine initializes itself by first referencing this file, and then building and testing all the designated database connections. In this way, an unlimited number of data source connections, database types, and even low-level driver combinations may be applied at runtime without affecting the higher-level database access logic.
By abstracting the connection using one or more delegators, OFBiz further offloads low-level database connection management from the developer, and handles all connection maintenance, data mappings, and the default transaction configuration for an unlimited number of target databases.
To configure one or more database connections, add datasource
element declarations with settings as shown here:
datasource element This element defines one or more database connections. (Note: some settings are database-specific. Shown here are the default settings for | |
---|---|
Configuration setting |
Usage |
|
The OFBiz utility program (Java class) that performs conversions and other helper functions on behalf of the Entity Engine for this particular database. |
|
Pointer to the field type definition XML document that describes the field type mappings for this database. Field type files are found in the |
|
Default schema name for PostgreSQL database schemas. Other databases may not require a default schema name. Configure accordingly. |
|
Instructs OFBiz to check the database against the configured data model (that is, against the configured entities for a data source) for missing entities and/or tables. |
|
Instructs OFBiz to add any missing tables and keys to the database based on the defined data model. Set this to |
|
Used to specify whether or not to set the "INITIALLY DEFERRED" option available in many databases when creating foreign keys. (Note: not all databases support this option). When enabled and supported, the foreign keys will not be checked until a transaction is committed. Defaults to "true". |
|
This value is used to compensate for a variation seen in some JDBC drivers where column names returned for aliased fields may be either the alias name or the full text of what makes up that alias name. See your database vendor's documentation for more information on settings per your target database. Defaults to "true". |
|
Used to specify the syntax to use when doing table joins in view-entity operations. Many databases are adopting the ANSI JOIN standard, but before that was introduced, theta joins were much more common. Two theta join styles are supported: Oracle and MS SQL. Valid values: Defaults to |
|
Used by OFBiz with the list iterator to determine default result set size. |
|
Instructs OFBiz on how to map database fields typed as Binary Large Objects (BLOBs). |
To specify that the Entity Engine should be connected to a database using a JDBC driver and to configure the specific connection parameters to pass, set the inline-jdbc
element attributes as detailed here:
Connection Configuration (inline-jdbc element) This element configures the database connection. | |
---|---|
|
Java class file name of the driver to use when accessing the database. This class file must be on the OFBiz CLASSPATH. |
|
Network-based location of the database. The syntax for database connection URI(s) vary from database to database. Please refer to your vendor's documentation for the appropriate syntax. For PostgreSQL, the following syntax is used:
|
|
The plain text username as established on the remote database for OFBiz to use to access the database. |
|
The plain text password as established on the remote database for OFBiz to use when connecting to the database. |
|
Transaction isolation levels determine how insulated concurrently active transactions are from one another. This attribute establishes the default row-level locking behavior for this database connection. While details of database transaction theory are beyond the scope of this book, it is recommended that most applications should use
Note: transactions discussed within the context of the Entity Engine's configuration are not the same transactions as configured for the Service Engine. |
|
Used to configure database connection pooling. The provided values are those found by experience to be most useful for the configured data source. The Entity Engine handles all connection acquisition and closure automatically (unless you otherwise instruct it). |
|
Used to configure database connection pooling (Minerva). The provided values are those found by experience to be most useful for the configured data source. |
Visit http://ofbiz.apache.org/docs/entityconfig.html for more information.
See also your vendor's database documentation.
3.139.240.244