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

Learn more

View all

Sign in to view all badges

accessToUnderlyingConnectionAllowed is coming false

Level 2
Level 2

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

3 Replies

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="" %><%
%><%@ 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"%><%
<cq:include script="head.jsp"/>
<%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;
          %><p>Number of results: <%=r%></p><%
   }catch (Exception e) {
        %><p>error! <%=e.getMessage()%></p><%


Level 2
Level 2

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 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.

Can you share which specific apache sling pool config you are referring here?