no data source with name "testConn" after asking 0 providers (Oracle AEM integration using jdbcpool configs)
Everytime after the deploying project bundle jdbc pool osgi config need to be resaved manually, or else I am getting the error at DataSourcePool.getDataSource("testConn")
unable to find the datasource with name "testConn", oracle bundle and my project bundles are active, how to make it pick automatically,
DataSourcePool.getDataSource("testConn") will be called everytime when the code attempts connecting to oracle
Config Name: com.day.commons.datasource.jdbcpool.JdbcPoolService-archival.config
Have tried to get the dataSource on every query exection, but still facing same
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.sql.DataSource;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Modified;
import org.osgi.service.component.annotations.Reference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.day.commons.datasource.poolservice.DataSourceNotFoundException;
import com.day.commons.datasource.poolservice.DataSourcePool;
@Component(service = OracleConnectorService.class, immediate = true)
public class OracleConnectorServiceImpl implements OracleConnectorService {
private static final Logger LOG = LoggerFactory.getLogger(OracleConnectorServiceImpl.class);
@3214626
private DataSourcePool dataSourceService;
Connection dbConnection = null;
PreparedStatement preStmt = null;
ResultSet rs = null;
DataSource dataSource = null;
@580286
@9182423
public void activate() {
try {
dataSource = (DataSource) dataSourceService.getDataSource(ArchivalConstants.ORACLE_DATASOURCE);
} catch (DataSourceNotFoundException e) {
LOG.error("Unable to establish db connections = {} ", e.getMessage());
}
}
@9944223
public ResultSet getResultSet(PreparedStatement preStmt) {
try {
rs = preStmt.executeQuery();
return rs;
} catch (SQLException e) {
LOG.error("get db results error = {} ", e);
}
return null;
}
@9944223
public int modifyData(PreparedStatement preStmt) {
try {
return preStmt.executeUpdate();
} catch (SQLException e) {
LOG.error("exception while executing update query {} ", e);
}
return 0;
}
@9944223
public PreparedStatement constructStmt(String query) {
setDataBaseConnection();
try {
if (null != dbConnection) {
preStmt = dbConnection.prepareStatement(query);
return preStmt;
}
} catch (SQLException e) {
LOG.error("exception while constructing statement {} ", e.getMessage());
}
return null;
}
@9944223
public void closeConnections() {
try {
if (null != preStmt)
preStmt.close();
if (null != rs)
rs.close();
if (null != dbConnection)
dbConnection.close();
} catch (SQLException e) {
LOG.error("Unable to close db connections {} ", e.getMessage());
}
}
public void setDataBaseConnection() {
try {
dbConnection = dataSource.getConnection();
if (null != dbConnection)
LOG.debug("Connection getMetaData = {} ", dbConnection.getMetaData().getURL());
} catch (SQLException e) {
LOG.error("Unable to establish db connections = {} ", e.getMessage());
}
}
}