Connect a Database as AEM Forms data source

Tested with the following setup:

  • Adobe Experience Manager 6.4.2.0
  • AEM Forms
  • CentOS 7.5
  • MySQL
Information Sources:

 

Download and install the JDBC Driver

  1. Go to https://dev.mysql.com/downloads/connector/j/ and download the "platform independent" version.
  2. Unzip mysql-connector-java-?.?.???.jar
  3. Go to http://localhost:4502/system/console/bundles
  4. In the table header, click on "Install/update", enable the start bundle option, refresh packages, select your file and on "Install or Update"

Configure the relational databases using AEM Web Console Configuration

  1. Go to AEM web console at http://[server]:[host]/system/console/configMgr.
  2. Look for Apache Sling Connection Pooled DataSource configuration. Tap to open the configuration in edit mode.
  3. In the configuration dialog, specify the details for the database you want to configure, such as:
    • Name of the data source (Similar to Page Title. i.e. "DB1 AEM_Schema")
    • Data source service property that stores the data source name . So far, I only got it to work with a value of "datasource.name"
    • Java class name for the JDBC driver: com.mysql.jdbc.Driver
    • JDBC connection URI
      You might have to add this to the connection URL in case of errors with MariaDB: ?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC
      Example: "jdbc:mysql://db.server.com:3306/aem_schema?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC"
    • Username and password to establish connection with the JDBC driver
    • Catalog (i.e. "aem_schema")

    Note:
    Ensure that you encrypt sensitive information like passwords before configuring the data source. To encrypt:
    Go to http://[server]:[port]/system/console/crypto.
    In the Plain Text field, specify the password or any string to encrypt and click Protect.
    The encrypted text appears in the Protected Text field that you can specify in the configuration.

  4. Enable Test on Borrow or Test on Return to specify that the objects are validated before being borrowed or returned from and to the pool, respectively.

  5. Specify a SQL SELECT query in the Validation Query field to validate connections from the pool. The query must return at least one row. Based on your database, specify one of the following:

    • SELECT 1 (MySQL and MS SQL) 
    • SELECT 1 from dual (Oracle)
  6. Tap Save to save the configuration.

     

     

     

     

  7.