private void syncDatabase() {
		/* Obtain connection to forum. */
		ForumSQLConnector ct = new ForumSQLConnector(mHost, mPort,
				mUserName, mPassword, mDbName);
		Connection con = null;
		con = ct.getConnection();
		if(con == null) return;
		/* Get map of forum group names -> ids */
		Map<String, Integer> group_forum_map = ct.getGroups(con);
		
		/* Intersect with configured groups to obtain set of valid ids. */
		Set<Integer> valid_id_set = new HashSet<>();
		for(String k : mValidGroups) {
			Integer id = group_forum_map.get(k);
			if(id != null)
				valid_id_set.add(id);
		}
		System.out.println("[DEBUG] getGroups: "+group_forum_map);
		/* Iterate over all players to be processed. */
		for(Entry<String, String> s : mData.entrySet()) {
			/* If the player's forum group exists. */
			if(group_forum_map.containsKey(s.getValue())) {
				/* Check if forum user exists. */
				String user = null;
				if(ct.isExistForumUser(con, s.getKey())) {
					/* Direct match. */
					user = s.getKey();
					System.out.println("[DEBUG] Forum user found.");
				} else {
					/* Match via minecraft_id field. */
					user = ct.getMinecraftForumUser(con, s.getKey());
					System.out.println("[DEBUG] Minecraft user found.");
				}
				/* Skip if user cannot be found. */
				if(user == null) {
					System.out.println("[DEBUG] No user found.");
					continue;
				}
					
				List<Integer> groups = ct.getSecondaryGroups(con, user);
				System.out.println("[DEBUG] getSecondaryGroups: "+Arrays.toString(groups.toArray()));
				/* Compose new list of groups. */
				List<Integer> new_groups = new ArrayList<>();
				/* Add the current primary group. */
				new_groups.add(group_forum_map.get(s.getValue()));
				/* Add all other non-syncable groups. */
				for(int g : groups) {
					if(!valid_id_set.contains(g)) {
						new_groups.add(g);
					}
				}
				/* Update secondary groups and set display group. */
				System.out.println("[DEBUG] setSecondaryGroups: "+Arrays.toString(new_groups.toArray()));
				ct.setSecondaryGroups(con, user, new_groups);
				ct.setDisplayGroup(con, user, 
						group_forum_map.get(s.getValue()));
			}
		}
		ct.closeConnection(con);
	}