Connect AEM with MySQL - AEM 6.4 | Community
Skip to main content
Level 2
May 14, 2019
Solved

Connect AEM with MySQL - AEM 6.4

  • May 14, 2019
  • 23 replies
  • 19752 views

Hi All,

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.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by rajkumark10

Hi All,

Above issue got fixed, Driver was the problem. We have installed mssql-jdbc-7.2.2.jre8.jar  driver jar and it is working fine as expected.

Thanks for all your inputs.

23 replies

Mayank_Gandhi
Adobe Employee
Adobe Employee
May 14, 2019

Hi Raj,

Do you want to connect Adaptive forms with Mysql?

Level 2
May 14, 2019

Hi Mayank,

Thanks for your reply. No forms, i am just trying to connect with SQL database from AEM using datasourcepool. I am able to connect with MYSQL but not able to get connection to SQL. I guess the driver name and JDBC connection will change for SQL. Any idea?

Regards,

Rajkumar K

Level 2
May 14, 2019

Hi,

I am using below details and getting the given error. Kindly help me to resolve the same.

JDBC Driver class : com.microsoft.sqlserver.jdbc.SQLServerDriver

JDBC connection : jdbc:sqlserver://<SQL Server URL>

Dependency used:

<dependency>

    <groupId>com.microsoft.sqlserver</groupId>

    <artifactId>mssql-jdbc</artifactId>

    <version>7.3.0.jre8-preview</version>

    <scope>provided</scope>

</dependency>

ERROR : No data source found with name 'test' (after asking 0 providers)

smacdonald2008
Level 10
May 14, 2019

We have plenty of video and articles on using MySQL with AEM. See:

Adobe Experience Manager Help | Querying MySQL data using an Adobe Experience Manager 6.4 DataSourcePool

This will show you step by step on how to get this use case implemented. See the video too at the end of this article.

Mayank_Gandhi
Adobe Employee
Adobe Employee
May 14, 2019
Level 2
May 14, 2019

Hi,

I have tried both the URLs. I can connect with MySql without any issues. I am facing issue with SQL database. is there anything i am missing in my configurations?

smacdonald2008
Level 10
May 14, 2019

I have only ever used MySQL for the DataSourcePool use case. 

I have SQL Server on my DEV Machine. I will test this out and post back.

I would think this could be a DRiver File issue or COnnection String issue when you setup the configuration required.

Mayank_Gandhi
Adobe Employee
Adobe Employee
May 14, 2019

Have you uploaded the bundled JDBC driver for sql server and configured the Datasource?

smacdonald2008
Level 10
May 14, 2019

I will attempt to get this use case working and make a new AEM/SQL SERVER article that shows everything required here.