throws Exception {
Connection con = null;
PreparedStatement statement = null;
ResultSet resultSet = null;
RepositoryCredentials repoCredentials = null;
try {
con = StratosDBUtils.getConnection();
String sql = "SELECT REPO_NAME,REPO_USER_NAME,REPO_USER_PASSWORD FROM REPOSITORY R, CARTRIDGE_SUBSCRIPTION C "
+ "WHERE C.REPO_ID=R.REPO_ID AND C.TENANT_ID=? AND C.CARTRIDGE=? AND C.STATE != 'UNSUBSCRIBED' ";
if (alias != null) {
sql = sql + " AND C.ALIAS=?";
}
statement = con.prepareStatement(sql);
statement.setInt(1, tenantId);
statement.setString(2, cartridge);
if (alias != null) {
statement.setString(3, alias);
}
if (log.isDebugEnabled()) {
log.debug("Executing query: " + sql);
}
resultSet = statement.executeQuery();
while (resultSet.next()) {
repoCredentials = new RepositoryCredentials();
repoCredentials.setUrl(resultSet.getString("REPO_NAME"));
repoCredentials.setUserName(resultSet.getString("REPO_USER_NAME"));
repoCredentials.setPassword(decryptPassword(resultSet.getString("REPO_USER_PASSWORD")));
}
} catch (Exception s) {
String msg = "Error while sql connection :" + s.getMessage();
log.error(msg, s);
throw s;