public static MailItem[] getMessages(String player) {
		if (!initialised) return null;
		Connection connection = null;
		PreparedStatement statement = null;
		ResultSet result = null;
		try {
			connection = DriverManager.getConnection(url, username, password);
			statement = connection.prepareStatement(GET_MESSAGES_COMMAND);
			statement.setString(1, player);
			result = statement.executeQuery();
			List<MailItem> items = new ArrayList<MailItem>();
			PlayerDetails recipient = new PlayerDetails(player, getEmailForPlayer(player));
			Map<Long, PlayerDetails> cachedDetails = new HashMap<Long, PlayerDetails>();
			while (result.next()) {
				String message = result.getString("message");
				long fromId = result.getLong("from") & 0xFFFFFFFF;
				PlayerDetails sender = cachedDetails.get(fromId);
				if (sender == null) {
					String from = getPlayerForId(fromId, connection);
					if (from == null) from = "[Unknown]";
					sender = new PlayerDetails(from, getEmailForPlayer(from));
					cachedDetails.put(fromId, sender);
				}
				long id = result.getLong("message_id") & 0xFFFFFFFF;
				long time = result.getLong("time");
				MailItem mail = new MailItem(sender, recipient, message, time);
				mail.setMessageId(id);
				items.add(mail);
			}
			return items.toArray(new MailItem[0]);
		} catch (SQLException e) {
			e.printStackTrace();
			return null;
		} finally {
			try {
				if (statement != null) {
					statement.close();
				}
				if (connection != null) {
					connection.close();
					connection = null;
				}
				if (result != null) {
					result.close();
				}
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
	}