private void insertProperty(String name, String value, boolean isEncrypted) {
        if (disableDatabasePersistence) {
            return;
        }

        Encryptor encryptor = getEncryptor(true);
        Connection con = null;
        PreparedStatement pstmt = null;
        try {
            con = DbConnectionManager.getConnection();
            pstmt = con.prepareStatement(INSERT_PROPERTY);
            final String valueToSave;
            final String ivString;
            if (isEncrypted) {
                final byte[] iv = new byte[16];
                new SecureRandom().nextBytes(iv);
                ivString = java.util.Base64.getEncoder().encodeToString(iv);
                valueToSave = encryptor.encrypt(value, iv);
            } else {
                ivString = null;
                valueToSave = value;
            }
            pstmt.setString(1, name);
            pstmt.setString(2, valueToSave);
            pstmt.setInt(3, isEncrypted ? 1 : 0);
            pstmt.setString(4, ivString);
            pstmt.executeUpdate();
        }
        catch (SQLException e) {
            Log.error(e.getMessage(), e);
        }
        finally {
            DbConnectionManager.closeConnection(pstmt, con);
        }
    }
Saves a property, optionally encrypting it

@param key
           The name of the property
@param value
           The value of the property
@param isEncrypted
           {@code true} to encrypt the property, {@code true} to leave in plain text
@return The previous value associated with {@code key}, or {@code null} if there was no mapping for
        {@code key}.
xmppserver/src/main/java/org/jivesoftware/util/JiveProperties.java