private DataSource initDataSource() {
String path = CarbonUtils.getCarbonConfigDirPath() + File.separator + "bam-publisher.properties";
Properties props = new Properties();
try {
props.load(new FileInputStream(path));
BasicDataSource dataSource = new BasicDataSource();
dataSource.setDriverClassName(props.getProperty("driver"));
dataSource.setUrl(props.getProperty("url"));
dataSource.setUsername(props.getProperty("username"));
dataSource.setPassword(props.getProperty("password"));
String validationQuery = props.getProperty("validationQuery");
if (validationQuery != null) {
dataSource.setValidationQuery(validationQuery);
}
String maxActive = props.getProperty("maxActive");
if (maxActive != null) {
dataSource.setMaxActive(Integer.parseInt(maxActive));
}
String initialSize = props.getProperty("initialSize");
if (initialSize != null) {
dataSource.setInitialSize(Integer.parseInt(initialSize));
}
String maxIdle = props.getProperty("maxIdle");
if (maxIdle != null) {
dataSource.setMaxIdle(Integer.parseInt(maxIdle));
}
log.info("Created new data source to: " + dataSource.getUrl());
return dataSource;
} catch (IOException e) {
log.error("Error while loading publisher DB configuration from: " + path, e);
return null;