Connecting to a remote database

A "remote" database is any data source that is not the default Derby database. A remote database may be network connected and/or installed on the local server. The Entity Engine supports simultaneous connections to an unlimited number of remote databases in addition to, or as a replacement for, the default instance of Derby.

Each remote database connection requires a datasource element entry in the entityengine.xml file. Adding and removing database connections may be performed at any time; however, entityengine.xml file changes are only effective upon OFBiz restart.

Getting ready

Collect all the necessary information required to connect to the remote database. In particular, you will need, at a minimum, the following information:

  • Database name.
  • Username and password for OFBiz to pass when negotiating connections to the remote database. In some cases, passwords are not required. Check your remote database setup for more information.
  • Database schema name, if appropriate. See the entityengine.xml file for examples.
  • Connection location information, including the IP address and port number to connect on (for IP-based network connections).

How to do it...

Once the initial information (as stated earlier) is collected, a remote database can be connected to by following these steps:

  1. Edit the entityengine.xml file. Add one or more datasource elements, one for each target database. Add one or more delegator elements with entity group configuration information telling the Entity Engine which entities are to be found on which target databases.
  2. Add or modify any field type definitions in the appropriate field type definition file for the target remote database.
  3. Add all necessary entity definitions to one or more entity definition file(s). Each table on the remote database requires an entity definition before it may be accessed through the Entity Engine.
  4. If necessary, add any entity group definitions to an entity group definition file.
  5. Make sure that any new entity group definition file is defined in the ofbiz-component.xml file.
  6. To make any Entity Engine configuration changes effective, restart OFBiz.

How it works...

Entity engine database connections and entity models are built whenever OFBiz is restarted as part of its initialization process. To manage database connections, connection pooling across all defined databases, data transfer, and data source transaction specifics, OFBiz consults the entityengine.xml file and automatically builds the internal control settings each time it is restarted.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.221.165.115