public void saveToDB() {
	if (!changed) {
	    return;
	}
	try {
	    Connection con = DatabaseConnection.getConnection();

	    PreparedStatement ps = con.prepareStatement("UPDATE storages SET slots = ?, meso = ? WHERE storageid = ?");
	    ps.setInt(1, slots);
	    ps.setInt(2, meso);
	    ps.setInt(3, id);
	    ps.executeUpdate();
	    ps.close();

	    ps = con.prepareStatement("DELETE FROM inventoryitems WHERE storageid = ?");
	    ps.setInt(1, id);
	    ps.executeUpdate();
	    ps.close();

	    ps = con.prepareStatement("INSERT INTO inventoryitems (storageid, itemid, inventorytype, position, quantity, owner, GM_Log, expiredate, flag) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)", DatabaseConnection.RETURN_GENERATED_KEYS);
	    PreparedStatement pse = con.prepareStatement("INSERT INTO inventoryequipment VALUES (DEFAULT, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");

	    for (IItem item : items) {
		ps.setInt(1, id);
		ps.setInt(2, item.getItemId());
		ps.setInt(3, item.getType()); // type.getType()
		ps.setInt(4, item.getPosition());
		ps.setInt(5, item.getQuantity());
		ps.setString(6, item.getOwner());
		ps.setString(7, item.getGMLog());
		ps.setLong(8, item.getExpiration());
		ps.setByte(9, item.getFlag());
		ps.executeUpdate();

		ResultSet rs = ps.getGeneratedKeys();
		int itemid;
		if (rs.next()) {
		    itemid = rs.getInt(1);
		} else {
		    throw new DatabaseException("Inserting char failed.");
		}
		if (item.getType() == 1) {
		    pse.setInt(1, itemid);
		    IEquip equip = (IEquip) item;
		    pse.setInt(2, equip.getUpgradeSlots());
		    pse.setInt(3, equip.getLevel());
		    pse.setInt(4, equip.getStr());
		    pse.setInt(5, equip.getDex());
		    pse.setInt(6, equip.getInt());
		    pse.setInt(7, equip.getLuk());
		    pse.setInt(8, equip.getHp());
		    pse.setInt(9, equip.getMp());
		    pse.setInt(10, equip.getWatk());
		    pse.setInt(11, equip.getMatk());
		    pse.setInt(12, equip.getWdef());
		    pse.setInt(13, equip.getMdef());
		    pse.setInt(14, equip.getAcc());
		    pse.setInt(15, equip.getAvoid());
		    pse.setInt(16, equip.getHands());
		    pse.setInt(17, equip.getSpeed());
		    pse.setInt(18, equip.getJump());
		    pse.setInt(19, equip.getRingId());
		    pse.setInt(20, equip.getViciousHammer());
		    pse.setInt(21, equip.getItemLevel());
		    pse.setInt(22, equip.getItemEXP());
		    pse.executeUpdate();
		}
	    }
	    ps.close();
	    pse.close();
	} catch (SQLException ex) {
	    System.err.println("Error saving storage" + ex);
	}
    }