It can happen when implementing AEM that you suddenly realize that the JCR database is not the best solution to store certain types of data.
For example, the JCR-SQL2 dialect is missing a lot of features that you’d expect from an typical database, so queries can become cumbersome. These limitations can be a real bummer if you’re trying to store thousands of products, blog posts or whatnot. For that reason, you may want to store certain data in an external database such as Oracle, MySQL, Neo4J, etc.
In enterprise environments, Oracle is often favored for RDBMS needs due its advanced features and support. With that in mind, I’ve decided to use Oracle as the basis for this tutorial, but the principles apply to any other external database.
There are essentially 3 components required to integrate AEM with an external database:
A JDBC driver bundle, which lets Java communicate with the database
A data source configuration, which represents the connection details of your database
A client, some Java class which actually runs a query
Follow this tutorial to find out how to set this all up. I’ve provided a Github link at the bottom of the article if you want to see a concrete implementation of this tutorial.