protected String getProperty(Connection dbConnection, String userName, String propertyName,
String profileName) throws UserStoreException {
String sqlStmt = realmConfig
.getUserStoreProperty(JDBCRealmConstants.GET_PROP_FOR_PROFILE);
if (sqlStmt == null) {
throw new UserStoreException("The sql statement for add user property sql is null");
}
PreparedStatement prepStmt = null;
ResultSet rs = null;
String value = null;
try {
prepStmt = dbConnection.prepareStatement(sqlStmt);
prepStmt.setString(1, userName);
prepStmt.setString(2, propertyName);
prepStmt.setString(3, profileName);
if (sqlStmt.contains(UserCoreConstants.UM_TENANT_COLUMN)) {
prepStmt.setInt(4, tenantId);
prepStmt.setInt(5, tenantId);
}
rs = prepStmt.executeQuery();
while (rs.next()) {
value = rs.getString(1);
}
return value;
} catch (SQLException e) {
log.error(e.getMessage(), e);
log.error("Using sql : " + sqlStmt);
throw new UserStoreException(e.getMessage(), e);
} finally {
DatabaseUtil.closeAllConnections(null, rs, prepStmt);
}
}