@Override
    public Group createGroup(String name) throws GroupNameInvalidException, GroupAlreadyExistsException {
        super.createGroup(name);

        if(name.trim().isEmpty()){
            throw new GroupNameInvalidException("Group name cannot be empty");
        }
        try {
            this.getGroup(name);
            throw new GroupAlreadyExistsException("A group with the same name already exists");
        } catch (GroupNotFoundException e) {
            //Expected, do nothing
        }
        Connection con = null;
        PreparedStatement pstmt = null;
        try {
            con = DbConnectionManager.getConnection();
            pstmt = con.prepareStatement(INSERT_GROUP);
            pstmt.setString(1, name);
            pstmt.setString(2, "");
            pstmt.executeUpdate();
        }
        catch (SQLException e) {
            Log.error(e.getMessage(), e);
        }
        finally {
            DbConnectionManager.closeConnection(pstmt, con);
        }

        // TODO Replace these two database queries with one. OF-2710
        Collection<JID> members = getMembers(name, false);
        Collection<JID> administrators = getMembers(name, true);

        return new Group(name, "", members, administrators);
    }
Database implementation of the GroupManager interface.

@author Matt Tucker
xmppserver/src/main/java/org/jivesoftware/openfire/group/DefaultGroupProvider.java