Prerequisites

Before you begin, ensure that you have the following:

Step 1: Configure MySQL database as data source

You can configure different types of data sources to create a form data model. For this tutorial, we will configure the MySQL database that you configured and populated with sample data. For information about other supported data sources and how to configure them, see AEM Forms Data Integration.

Do the following to configure your MySQL database:

  1. Install JDBC driver for MySQL database as an OSGi bundle:

    1. Log in to AEM Forms Author Instance as an administrator and go to AEM web console bundles. The default URL is http://localhost:4502/system/console/bundles.

    2. Tap Install/Update. An Upload / Install Bundles dialog appears.

    3. Tap Choose File to browse and select the MySQL JDBC driver OSGi bundle. Select Start Bundle and Refresh Packages, and tap Install or Update. Ensure that the Oracle Corporation’s JDBC Driver for MySQL is active. The driver is installed.

  2. Configure MySQL database as a data source:

    1. Go to AEM web console at http://localhost:4502/system/console/configMgr.

    2. Locate Apache Sling Connection Pooled DataSource configuration. Tap to open the configuration in edit mode.

    3. In the configuration dialog, specify the following details:

      • Datasource name: You can specify any name. For example, specify WeRetailMySQL.
      • DataSource service property name: Specify name of the service property containing the DataSource name. It is specified while registering the data source instance as OSGi service. For example, datasource.name.
      • JDBC driver class: Specify Java class name of the JDBC driver. For MySQL database, specify com.mysql.jdbc.Driver.
      • JDBC connection URI: Specify connection URL of the database. For MySQL database running on port 3306 and schema weretail, the URL is: jdbc:mysql://[server]:3306/weretail?autoReconnect=true&useUnicode=true&characterEncoding=utf-8
      • Username: Username of the database. It is required to enable JDBC driver to establish a connection with the database.
      • Password: Password of the database. It is required to enable JDBC driver to establish a connection with the database.
      • Test on Borrow: Enable the Test on Borrow option.
      • Test on Return: Enable the Test on Return option.
      • Validation Query: Specify a SQL SELECT query to validate connections from the pool. The query must return at least one row. For example, select * from customerdetails.
      • Transaction Isolation: Set the value to READ_COMMITTED.

      Leave other properties with default values and tap Save.

    A configuration similar to the following is created.

    relational-database-data-source-configuration