private void purgeItems()
    {
		boolean abortTransaction = false;
        Connection con = null;
		PreparedStatement nodeConfig = null;
		PreparedStatement purgeNode = null;
        ResultSet rs = null;

        try
        {
            con = DbConnectionManager.getTransactionConnection();
			nodeConfig = con.prepareStatement(PERSISTENT_NODES);
            rs = nodeConfig.executeQuery();
            purgeNode = con.prepareStatement(getPurgeStatement(DbConnectionManager.getDatabaseType()));

            boolean hasBatchItems = false;
            while (rs.next())
            {
                hasBatchItems = true;
            	String svcId = rs.getString(1);
            	String nodeId = rs.getString(2);
            	int maxItems = rs.getInt(3);

				setPurgeParams(DbConnectionManager.getDatabaseType(), purgeNode, svcId, nodeId, maxItems);

				purgeNode.addBatch();
            }
			if (hasBatchItems) purgeNode.executeBatch();
		}
		catch (Exception sqle)
		{
            log.error("An exception occurred while trying to purge all items from the database that exceed the defined item count on all nodes.", sqle);
			abortTransaction = true;
		}
		finally
		{
            DbConnectionManager.closeResultSet(rs);
            DbConnectionManager.closeStatement(nodeConfig);
            DbConnectionManager.closeStatement(purgeNode);
            DbConnectionManager.closeTransactionConnection(con, abortTransaction);
		}
    }
Purges all items from the database that exceed the defined item count on
all nodes.
xmppserver/src/main/java/org/jivesoftware/openfire/pubsub/DefaultPubSubPersistenceProvider.java