@Override
    public PEPService loadPEPServiceFromDB(JID jid) {
        PEPService pepService = null;

        Connection con = null;
        PreparedStatement pstmt = null;
        ResultSet rs = null;
        try {
            con = DbConnectionManager.getConnection();
            // Get all PEP services
            pstmt = con.prepareStatement(GET_PEP_SERVICE);
            pstmt.setString(1, jid.toString());
            rs = pstmt.executeQuery();
            // Restore old PEPService
            while (rs.next()) {
                String serviceID = rs.getString(1);
                if ( !jid.toString().equals( serviceID )) {
                    log.warn( "Loading a PEP service for {} that has a different name: {}", jid, serviceID );
                }
                // Create a new PEPService
                pepService = new PEPService(XMPPServer.getInstance(), jid);
            }
        } catch (SQLException sqle) {
            log.error("An exception occurred while trying to load a PEP service from the database for {}", jid, sqle);
        } finally {
            DbConnectionManager.closeConnection(rs, pstmt, con);
        }

        return pepService;
    }
Writes large changesets to the database, using batches and transactions when
available.

The 'delete' list takes precedence over the 'add' list: when an item exists
on both lists, it is removed (and not re-added) to the database.

To prevent duplicates to exist in the database, this method will attempt to
remove all items to-be-added from the database, before re-adding them.

Note that multiple attempts to write items to the DB are made:
1) insert all pending items in a single batch
2) if the batch insert fails, retry by inserting each item separately

@param addList A list of items to be added to the database.
@param delList A list of items to be removed from the database.
xmppserver/src/main/java/org/jivesoftware/openfire/pubsub/DefaultPubSubPersistenceProvider.java