Oracle, SQL Server, MySQL, and DB2 Persistence Layers

Orbeon Forms 4 documentation

Legacy Orbeon Forms 3.9 documentation

In your properties-local.xml:
  1. Map an app, form, form type to the Oracle or MySQL persistence layer using the*.*.* wildcard property, For instance, the following indicates that all the form definition and form data in the acme "app" are stored in Oracle:

    <property as="xs:anyURI"  name="*.*"

  2. Set the value of the property for Oracle or for MySQL to match the name of the resource you setup in server.xml. For instance, if in server.xml the resource name is jdbc/oracle, then the property should be set to just oracle, as in:

    <property as="xs:anyURI" name="" value="oracle"/>

Dynamic datasource for MySQL

You select the datasource used by the MySQL persistence layer with the configuration property. If you have multiple MySQL datasources, you can dynamically choose which one the MySQL persistence layer uses by setting the Orbeon-Datasource HTTP header. When the header is set, it takes precedence over the value of the property. In addition to setting the header, you need to add the following property so Form Runner forwards that header to the MySQL persistence layer:

<property as="xs:string" name="oxf.http.forward-headers" value="Orbeon-Datasource"/>

The header must be present in both the HTTP requests that return a web page and the Ajax requests. This assumes that you have your own "proxy" (for instance a servlet filter) that receives requests from the browser and adds the header before passing requests along to Orbeon Forms. For security reasons, you should never return the header to the browser, as this would enable malicious users to access any datasource they want by changing the value of the header. Typically, your proxy will work as follows:

Step Users / browser Your proxy Orbeon Forms / Persistence layer 
A.1 Logs in, or accesses the system for the first time loading a web page.
A.2   Creates a session, and stores in the session the datasource to use based on who the user is.  
B.1 Accesses a Orbeon Forms page or sends an Ajax request.    
B.2   Based on the information stored in the session, finds what datasource to use, and adds the Orbeon-Datasource header to the request it passes along to Orbeon Forms. This header is just added to the request going to Orbeon Forms, and is not returned to the browser.  
B.3     Finds the Orbeon-Datasource header and uses the datasource specified by that header rather than the one specified by the .mysql.datasource property.