accessToUnderlyingConnectionAllowed is coming false | Community
Skip to main content
amitcsknit
Level 2
July 22, 2020
Question

accessToUnderlyingConnectionAllowed is coming false

  • July 22, 2020
  • 1 reply
  • 1384 views

I am trying to make connection in mysql database via putting property inside configMgr with jdpc pool configurations

 

datasource is coming from org.apache.commons.dbcp.PoolingDataSource but when i trying to access connection inside is, its null and if i check few attributes , i found one interesting one as accessToUnderlyingConnectionAllowed is coming false

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

1 reply

vanegi
Adobe Employee
Adobe Employee
July 22, 2020

Can you check with the following example JSP code that obtains an instance of the hsqldbds data source, and see if connection is really happening?

 

<%@include file="/libs/foundation/global.jsp"%><%
%><%@page session="false"%><%
%><%@ page import="com.day.commons.datasource.poolservice.DataSourcePool" %><%
%><%@ page import="javax.sql.DataSource" %><%
%><%@ page import="java.sql.Connection" %><%
%><%@ page import="java.sql.SQLException" %><%
%><%@ page import="java.sql.Statement" %><%
%><%@ page import="java.sql.ResultSet"%><%
%><html>
<cq:include script="head.jsp"/>
<body>
<%DataSourcePool dspService = sling.getService(DataSourcePool.class);
  try {
     DataSource ds = (DataSource) dspService.getDataSource("hsqldbds"); 
     if(ds != null) {
         %><p>Obtained the datasource!</p><%
         %><%final Connection connection = ds.getConnection();
          final Statement statement = connection.createStatement();
          final ResultSet resultSet = statement.executeQuery("SELECT * from INFORMATION_SCHEMA.SYSTEM_USERS"); 
          int r=0;
          while(resultSet.next()){
             r=r+1;
          } 
          resultSet.close();
          %><p>Number of results: <%=r%></p><%
      } 
   }catch (Exception e) {
        %><p>error! <%=e.getMessage()%></p><%
    } 
%></body>
</html>

  

amitcsknit
Level 2
July 23, 2020

thanks @ vanegi for your reply.. When i rechecked everything i found database was down....after restarting it worked. but i have another query that when we put my configuration inside jdbc pool it worked. What i have to import in place of com.day.commons.datasource.poolservice.DataSourcePool to use apache sling data pool service as it was not picking datasource configuration from apache sling pool configurations present inside configMgr. then i use jdbc pool configuration & it is working.