class JDBCConnection implements ObjectStoreConnection {

    @Override
    public DomainGroupMember getPrincipalGroups(String principal, String domainName) {

        final String caller = "getPrincipalGroups";

        int principalId = getPrincipalId(principal);
        if (principalId == 0) {
            throw notFoundError(caller, ZMSConsts.OBJECT_PRINCIPAL, principal);
        }

        DomainGroupMember domainGroupMember = new DomainGroupMember();
        domainGroupMember.setMemberGroups(new ArrayList<>());
        domainGroupMember.setMemberName(principal);
        if (StringUtil.isEmpty(domainName)) {
            try (PreparedStatement ps = con.prepareStatement(SQL_GET_PRINCIPAL_GROUPS)) {
                ps.setInt(1, principalId);
                return getGroupsForPrincipal(caller, domainGroupMember, ps);
            } catch (SQLException ex) {
                throw sqlError(ex, caller);
            }
        } else {
            int domainId = getDomainId(domainName);
            if (domainId == 0) {
                throw notFoundError(caller, ZMSConsts.OBJECT_DOMAIN, domainName);
            }
            try (PreparedStatement ps = con.prepareStatement(SQL_GET_PRINCIPAL_GROUPS_DOMAIN)) {
                ps.setInt(1, principalId);
                ps.setInt(2, domainId);
                return getGroupsForPrincipal(caller, domainGroupMember, ps);
            } catch (SQLException ex) {
                throw sqlError(ex, caller);
            }
        }
    }

    public  JDBCConnection(Connection con, boolean autoCommit);

}