Hi Team,
I am trying to connect with Oracle database 19c. I have given JDBC configuration and used the below code. But in the below code, I am getting datasource pool as "No data source found with name 'AppCloudDB' (after asking 0 providers)".
![image.png image.png](https://experienceleaguecommunities.adobe.com/t5/image/serverpage/image-id/23301i232623952B220BA0/image-size/large/is-moderation-mode/true?v=v2&px=999)
Can you please help me to find where I am doing a mistake?
@SlingServlet(paths = "/bin/getDB", methods = "GET", metatype=true, label = "AppCloud Database Connectivity",
description = "AppCloud Database Connectivity")
public class TestingDB extends SlingAllMethodsServlet{
/**
*
*/
private static final long serialVersionUID = 1L;
protected static final Logger LOGGER = LoggerFactory.getLogger(TestingDB.class);
@Reference
public DataSourcePool dataSourcePoolService;
ResultSet rs = null;
PreparedStatement pstmt = null;
PrintWriter writer = null;
@Override
protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response)
throws ServletException, IOException {
writer = response.getWriter();
LOGGER.debug("Entering appcloud test DB class");
int results = getData();
if(results > 0){
writer.write("Connection to DB Successful. Demo Query retrieves "+results+ " items.");
}else{
writer.write("\n\nConnection to DB UnSuccessful. Demo Query retrieves "+results+ " items.");
}
LOGGER.error("--> Total Results: "+results);
}
public int getData(){
int rowCount = 0;
Connection c = null;
try {
c = getConnection();
String query = "Select * FROM ac_content_type";
pstmt = c.prepareStatement(query);
rs = pstmt.executeQuery();
while(rs.next()){
rowCount++;
}
LOGGER.debug("Total Rows Retrieved"+rowCount);
LOGGER.debug("Exiting appcloud test DB class");
} catch (DataSourceNotFoundException e) {
LOGGER.error("DataSourceNotFoundException while attempting to find a data source. make sure data source exists in AEM configuration.");
writer.write("DataSourceNotFoundException while attempting to find a data source. make sure data source exists in AEM configuration. Exception received is: "+e);
} catch (SQLException e) {
LOGGER.error("SQLException while connecting to AppCloud DB.");
writer.write("SQLException while connecting to AppCloud DB. Exception received is: "+e);
} finally {
try {
c.close();
} catch (SQLException e) {
LOGGER.error(AppCloudConstants.SQL_EXCEPTION, e);
}
}
return rowCount;
}
private Connection getConnection() throws DataSourceNotFoundException, SQLException{
DataSource ds = null;
Connection c = null;
ds = (DataSource) dataSourcePoolService.getDataSource("AppCloudDB");
c = ds.getConnection();
return c;
}
}
We are using ojdbc14.jar with it.
We were using 6.3 till now and things were working fine. With 6.5, its not creating data source.
Do we have to do anything in 6.5 for datasource.