private final void writeToDB(final boolean bDisband) {
	try {
	    Connection con = DatabaseConnection.getConnection();
	    if (!bDisband) {
		StringBuilder buf = new StringBuilder("UPDATE guilds SET GP = ?, logo = ?, logoColor = ?, logoBG = ?, logoBGColor = ?, ");
		for (int i = 1; i < 6; i++) {
		    buf.append("rank" + i + "title = ?, ");
		}
		buf.append("capacity = ?, " + "notice = ?, alliance = ? WHERE guildid = ?");

		PreparedStatement ps = con.prepareStatement(buf.toString());
		ps.setInt(1, gp);
		ps.setInt(2, logo);
		ps.setInt(3, logoColor);
		ps.setInt(4, logoBG);
		ps.setInt(5, logoBGColor);
		ps.setString(6, rankTitles[0]);
		ps.setString(7, rankTitles[1]);
		ps.setString(8, rankTitles[2]);
		ps.setString(9, rankTitles[3]);
		ps.setString(10, rankTitles[4]);
		ps.setInt(11, capacity);
		ps.setString(12, notice);
		ps.setInt(13, allianceid);
		ps.setInt(14, id);
		ps.execute();
		ps.close();
	    } else {
		PreparedStatement ps = con.prepareStatement("UPDATE characters SET guildid = 0, guildrank = 5 WHERE guildid = ?");
		ps.setInt(1, id);
		ps.execute();
		ps.close();

		//delete the alliance
		if (allianceid > 0) {
		    if (getAlliance(null).getGuilds().get(0).getLeaderId() == getLeaderId()) {
			ps = con.prepareStatement("DELETE FROM alliances WHERE id = ?");
			ps.setInt(1, allianceid);
			ps.execute();
			ps.close();
		    }
		}

		ps = con.prepareStatement("DELETE FROM guilds WHERE guildid = ?");
		ps.setInt(1, id);
		ps.execute();
		ps.close();

		broadcast(GuildPacket.guildDisband(id));
	    }
	} catch (SQLException se) {
	    System.err.println("Error saving guild to SQL" + se);
	}
    }