Connect AEM with MySQL - AEM 6.4 | Community
Skip to main content
Level 2
May 14, 2019 9:54 AM UTC
Solved

Connect AEM with MySQL - AEM 6.4

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.
rajkumark10Accepted solution
Level 2
Jun 10, 2019 7:23 AM UTC

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.

24 replies

Mayank_Gandhi
Employee
Jun 11, 2019 5:41 PM UTC

Good to know Raj that it is resolved!

Translate
rajkumark10AuthorAccepted solution
Level 2
Jun 10, 2019 7:23 AM UTC

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.

Translate
Level 2
Jun 7, 2019 9:08 AM UTC

Hi Mayank Gandhi​,

Sorry, Below is the issue i am getting.

ERROR : com.microsoft.sqlserver.jdbc.SQLServerDriver not found

Translate
Mayank_Gandhi
Employee
Jun 6, 2019 5:41 PM UTC

Upload the code somewhere.Why are you getting mysql error.

Translate
Mayank_Gandhi
Employee
Jun 6, 2019 5:39 PM UTC

He is having an issue with Microsoft SQL, MySQL is working fine.

Translate
New Participant
Aug 31, 2021 8:38 AM UTC

Hi,

You can share me your scouce code connect to MySQL with AEM.

Thanks a lots

Translate
Employee
Jun 6, 2019 5:25 PM UTC

I just tried on my system

I got the osgi bundle from here and it worked fine

https://search.maven.org/search?q=g:mysql%20AND%20a:mysql-connector-java

Translate
Level 2
Jun 6, 2019 10:21 AM UTC

Hi albinissac​ and Mayank Gandhi​,

Thanks for your inputs. As i informed before, I am not facing issue for mysql but for mssql server. Also as you said, i have tried with class.fornames(); and still facing issue. In this method even mysql not able to find driver.

Is there any reference for mssql connectivity from AEM. Kindly share.

ERROR : com.mysql.jdbc.Driver not found by

Regards,

Rajkumar K

Translate
Mayank_Gandhi
Employee
Jun 3, 2019 1:33 PM UTC

Looks like your code is missing javax.net.ssl package.

See the manifest file used for the below example of MYSQL and try to contemplate your manifest file.

Adobe Experience Manager Help | Creating an Adobe Experience Manager web application that uses MySQL

Translate
Level 2
Jun 1, 2019 9:12 PM UTC