Source:
<code>public AssociatedAccountDTO[] getAssociatedIDs() throws UserProfileException { Connection connection = null; PreparedStatement prepStmt = null; ResultSet resultSet; String sql = null; String tenantAwareUsername = MultitenantUtils.getTenantAwareUsername(CarbonContext.getThreadLocalCarbonContext() .getUsername()); String domainName = getDomainName(tenantAwareUsername); tenantAwareUsername = getUsernameWithoutDomain(tenantAwareUsername); List<AssociatedAccountDTO> associatedIDs = new ArrayList<AssociatedAccountDTO>(); int tenantID = CarbonContext.getThreadLocalCarbonContext().getTenantId(); try { connection = JDBCPersistenceManager.getInstance().getDBConnection(); sql = "SELECT IDP.NAME, IDP_USER_ID FROM IDN_ASSOCIATED_ID JOIN IDP ON IDN_ASSOCIATED_ID.IDP_ID = IDP.ID " + "WHERE IDN_ASSOCIATED_ID.TENANT_ID = ? AND USER_NAME = ? AND DOMAIN_ID = " + "(SELECT UM_DOMAIN_ID FROM UM_DOMAIN WHERE UM_DOMAIN_NAME = ? AND UM_TENANT_ID= ?)"; prepStmt = connection.prepareStatement(sql); prepStmt.setInt(1, tenantID); prepStmt.setString(2, tenantAwareUsername); prepStmt.setString(3, domainName); prepStmt.setInt(4, tenantID); resultSet = prepStmt.executeQuery(); while (resultSet.next()) { associatedIDs.add(new AssociatedAccountDTO(resultSet.getString(1), resultSet.getString(2))); } if(!associatedIDs.isEmpty()) { return associatedIDs.toArray(new AssociatedAccountDTO[associatedIDs.size()]); } else { return new AssociatedAccountDTO[0]; } } catch (IdentityException e) { log.error(persistenceErrorMsg, e); throw new UserProfileException(persistenceErrorMsg, e); } catch (SQLException e) { <START> log.error(SQLErrorMsg + sql); <END> log.error(e.getMessage(), e); } finally { IdentityDatabaseUtil.closeAllConnections(connection, null, prepStmt); } return new AssociatedAccountDTO[0]; }</code><technical_language>add error log for stack trace message</technical_language>

Target:
public AssociatedAccountDTO[] getAssociatedIDs() throws UserProfileException { Connection connection = null; PreparedStatement prepStmt = null; ResultSet resultSet; String sql = null; String tenantAwareUsername = MultitenantUtils.getTenantAwareUsername(CarbonContext.getThreadLocalCarbonContext() .getUsername()); String domainName = getDomainName(tenantAwareUsername); tenantAwareUsername = getUsernameWithoutDomain(tenantAwareUsername); List<AssociatedAccountDTO> associatedIDs = new ArrayList<AssociatedAccountDTO>(); int tenantID = CarbonContext.getThreadLocalCarbonContext().getTenantId(); try { connection = JDBCPersistenceManager.getInstance().getDBConnection(); sql = "SELECT IDP.NAME, IDP_USER_ID FROM IDN_ASSOCIATED_ID JOIN IDP ON IDN_ASSOCIATED_ID.IDP_ID = IDP.ID " + "WHERE IDN_ASSOCIATED_ID.TENANT_ID = ? AND USER_NAME = ? AND DOMAIN_ID = " + "(SELECT UM_DOMAIN_ID FROM UM_DOMAIN WHERE UM_DOMAIN_NAME = ? AND UM_TENANT_ID= ?)"; prepStmt = connection.prepareStatement(sql); prepStmt.setInt(1, tenantID); prepStmt.setString(2, tenantAwareUsername); prepStmt.setString(3, domainName); prepStmt.setInt(4, tenantID); resultSet = prepStmt.executeQuery(); while (resultSet.next()) { associatedIDs.add(new AssociatedAccountDTO(resultSet.getString(1), resultSet.getString(2))); } if(!associatedIDs.isEmpty()) { return associatedIDs.toArray(new AssociatedAccountDTO[associatedIDs.size()]); } else { return new AssociatedAccountDTO[0]; } } catch (IdentityException e) { log.error(persistenceErrorMsg, e); throw new UserProfileException(persistenceErrorMsg, e); } catch (SQLException e) { log.error(SQLErrorMsg + sql, e); } finally { IdentityDatabaseUtil.closeAllConnections(connection, null, prepStmt); } return new AssociatedAccountDTO[0]; }