How to create a Microsoft SQL connection on AEM Forms 6.3?

msgtowers 19-10-2017

I am new to AEM Forms 6.3, but I have used LiveCycle ES4.  Under LiveCycle ES4 to create a connection, I added the SQL connection string to the adobe-ds.xml file under the deploy directory.  After restarting JBoss, I could use to connection to create a WSDL.  On AEM Forms 6.3 to add a SQL connection, do I have to use configMgr?  If I have to use it, how do I install it?  Thank you.

Accepted Solutions (1)

Accepted Solutions (1)

smacdonald2008 19-10-2017

In AEM - to connect to a Database - you need to write OSGi logic and use a DataSourcePool.

See this new Article we just put out.

Scott's Digital Community: Creating a Mail List Component for the Experience Manager Toy Store Site

It shows you how to write a OSGi service that uses a DataSourcePool. It also shows you how to configure a DataSourcePool service.

We used MySQL as an example - but this will point you in the right direction.

To get the data from a form to an OSGi, you can write a custom Form action too:

Scott's Digital Community: Creating a custom action for an Adobe Experience Manager Form component

Hope this helps....

Answers (3)

Answers (3)

Mayank_Gandhi
Employee
14-05-2019

6.3 onwards, in case you want to configure your Adaptive forms to connect to Database or any other Datasource you can use Form Data Model.

Form Data Model(FDM): AEM Forms data integration module allows you to create a form data model from disparate backend data sources such as AEM user profile, RESTful web services, SOAP-based web services, OData services, and relational databases. You can configure data model objects and services in a form data model and associate it with an adaptive form. Adaptive form fields are bound to data model object properties. The services enable you to prefill the adaptive form and write submitted form data back to the data model object.

Adobe Experience Manager Help | AEM Forms Data Integration

rajkumark10 13-05-2019

Hi Smacdonald2008,

I am trying to connect with MYSQL. I have given JDBC configuration and used below code. But in below code i am getting datasource pool as null. Can you please help me to find where i am doing mistake?

@Reference

private DataSourcePool ds;

 

//Returns a connection using the configured DataSourcePool

private Connection getConnection()

{

LOGGER.info("************Inside get connection*********" + ds);

         DataSource dspService = null;

         Connection con = null;

        

         try

         {

        dspService = (DataSource) ds.getDataSource("hsqldbds");

        LOGGER.info("************Inside IF*********");

        if(dspService != null) {

        LOGGER.info("************Inside IF*********");

                 final Connection connection = ((DataSource) dspService).getConnection();

                  final Statement statement = connection.createStatement();

                 final ResultSet resultSet = statement.executeQuery("SELECT * from pet");

                  int r=0;

                  LOGGER.info("************Working*********");

                  while(resultSet.next()){

                     r=r+1;

                  }

                  resultSet.close();

                  }

            

           }

         catch (Exception e)

         {

        LOGGER.info("************ERROR*********" + e.getMessage());

             e.printStackTrace();

         }

             return con;

}

Also, Can you share me driver need to be used for SQL DB in AEM 6.4.