Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

[AEM Gems Webinar] Accelerating Experience Manager as a Cloud Service development with Rapid Development Environments
SOLVED

Connect AEM with MySQL - AEM 6.4

Avatar

Level 2

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.

1 Accepted Solution

Avatar

Correct answer by
Level 2

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.

View solution in original post

0 Replies

Avatar

Employee Advisor

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

Avatar

Level 2

Hi Mayank Gandhi​,

Sorry, Below is the issue i am getting.

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

Avatar

Correct answer by
Level 2

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.