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
BedrockMission!

Learn More

View all

Sign in to view all badges

accessToUnderlyingConnectionAllowed is coming false

Avatar

Avatar
Give Back 3
Level 1
amitcsknit
Level 1

Likes

2 likes

Total Posts

14 posts

Correct Reply

0 solutions
Top badges earned
Give Back 3
Give Back
Boost 1
View profile

Avatar
Give Back 3
Level 1
amitcsknit
Level 1

Likes

2 likes

Total Posts

14 posts

Correct Reply

0 solutions
Top badges earned
Give Back 3
Give Back
Boost 1
View profile
amitcsknit
Level 1

22-07-2020

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

Accepted Solutions (0)

Answers (1)

Answers (1)

Avatar

Avatar
Give Back 5
Employee
vanegi
Employee

Likes

389 likes

Total Posts

377 posts

Correct Reply

147 solutions
Top badges earned
Give Back 5
Give Back 3
Give Back 10
Give Back
Boost 50
View profile

Avatar
Give Back 5
Employee
vanegi
Employee

Likes

389 likes

Total Posts

377 posts

Correct Reply

147 solutions
Top badges earned
Give Back 5
Give Back 3
Give Back 10
Give Back
Boost 50
View profile
vanegi
Employee

22-07-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>