Configure data source

Last update: 2023-11-30
  • Created for:
  • Beginner

There are many ways with which AEM enables integration with an external database. One of the most common ways to integrate a database is by using Apache Sling Connection Pooled DataSource configuration properties through the configMgr.
The first step is to download and deploy the appropriate MySql drivers in AEM.
Create Apache Sling Connection Pooled DataSource and provide the properties as specified in the screen shot below. The database schema is provided to you as part of this tutorial assets.


Database has one table called formdata with the 3 columns as shown in the screen-shot below.



Please make sure you name your datasource aemformstutorial. The sample code uses the name to connect to the database.

Property Name Value
Datasource Name SaveAndContinue
JDBC Driver Class com.mysql.cj.jdbc.Driver
JDBC connection uri jdbc:mysql://localhost:3306/aemformstutorial


The SQL file to create the schema can be downloaded from here. You will need to import this file using MySql workbench to create the schema and the table.

Next Steps

Create an OSGi service to store and fetch data in database

On this page