private void writeToDatabase(String username, String offlinePresence, Date offlinePresenceDate) {
        // delete existing offline presence (if any)
        deleteOfflinePresenceFromDB(username);

        // Insert data into the database.
        Connection con = null;
        PreparedStatement pstmt = null;
        try {
            con = DbConnectionManager.getConnection();
            pstmt = con.prepareStatement(INSERT_OFFLINE_PRESENCE);
            pstmt.setString(1, username);
            if (offlinePresence != null) {
                DbConnectionManager.setLargeTextField(pstmt, 2, offlinePresence);
            } else {
                pstmt.setNull(2, Types.VARCHAR);
            }
            pstmt.setString(3, StringUtils.dateToMillis(offlinePresenceDate));
            pstmt.execute();
        } catch (SQLException sqle) {
            Log.error("Error storing offline presence of user: " + username, sqle);
        } finally {
            DbConnectionManager.closeConnection(pstmt, con);
        }
    }
Simple in memory implementation of the PresenceManager interface.

@author Iain Shigeoka
xmppserver/src/main/java/org/jivesoftware/openfire/spi/PresenceManagerImpl.java