AEM Forms with MySQL
In this blog, I will discuss how the AEM 6.5.x Adaptive form will work with MySQL. Let’s start the discussion:
How to connect adaptive forms to the MySQL database?
For Connecting Adaptive Form to the MySQL database server, below mentioned steps need to be followed.
Step 1: Install mysql-connector-j bundle in AEM
- Go to the URL http://localhost:4502/system/console/bundles.
- Click on the Install/Update button on the top right corner of the console.
- Click on the choose file option in the popup and select the mysql-connector-j file to check the Start Bundle checkbox.
- Click on the “Install or Update” button.
- Search for MySql in the config manager and check if the bundle is active. If it is active we are all set with MySQL driver upload.
Step 2: Configure JDBC DataSource
Below are the steps for configuring “Apache Sling Connection Pooled Datasource”. Configuration screenshot has lots of fields that can be configured but I am only addressing those which are minimally required for the basic connection.
- Go to the URL http://localhost:4502/system/console/configMgr.
- Search for the Apache Sling Connection Pooled DataSource node in the config manager and open the node in edit mode.
- JDBC driver class must contain the path of the bundle of MySQL-connector-j.
- JDBC connection URI must contain the value with the database URL path in the blow format-
jdbc:mysql://[host]:[port]/[schema_name].
for ex:
jdbc: mysql ://localhost:5432/test
- Enter the user name and the password in the fields present below.
- Click on the save button to save the configuration of the database.
Step 3: Create Form Data Model
Below are the steps for creating an Adaptive Form “Form Data Model” object.
- Go to the URL http://localhost:4502/aem/start.html.
- Go to the forms and select Data Integrations.
- Click on Create and select the Form Data Model.
- Create your Model then we will be able to see our database option.
- Select your database model and click on Create.
- Select the edit option from the popup.
- Then expand the data source listed in the left pane.
Steps 4: Steps to add Form Data Model objects and Services:
- Go to the URL http://localhost:4502/aem/start.html.
- Go to the Forms option on the home screen and then select the Data Integration option from the Forms option list.
- Then expand the data source listed in the left pane.
- Select the required data model object and service you want to add to the form data and click on Add Selected.
- After clicking the Add Selected button we will see the graphical representation of all data model objects and properties added to the form data model
- All the added Services are listed in the Services tab
Happy Learning!
By Akshit Gahlaut
Recent Comments