public static boolean addMail(MailItem mail) {
		if (!initialised) return false;
		Connection connection = null;
		PreparedStatement statement = null;
		ResultSet result = null;
		try {
			connection = DriverManager.getConnection(url, username, password);
			statement = connection.prepareStatement(INSERT_MESSAGE_COMMAND, Statement.RETURN_GENERATED_KEYS);
			// Columns: message_id, message, time, from
			long fromId = getIdForPlayer(mail.getFrom().getPlayer(), connection);
			long toId = getIdForPlayer(mail.getTo().getPlayer(), connection);
			if (fromId == -1 || toId == -1) return false;
			statement.setLong(1, 0); // 0 means auto-increment
			statement.setString(2, mail.getMessage());
			statement.setLong(3, mail.getTime());
			statement.setLong(4, fromId);
			statement.executeUpdate();
			result = statement.getGeneratedKeys();
			
			if (result.next()) {
				mail.setMessageId(result.getLong(1));
				statement.close();
				statement = connection.prepareStatement(INSERT_MESSAGE_PLAYER_JOIN_COMMAND);
				// Columns: message_id, player_id
				statement.setLong(1, mail.getMessageId());
				statement.setLong(2, toId);
				statement.executeUpdate();
				statement.close();
				
				statement = connection.prepareStatement(INSERT_MESSAGE_TO_EMAIL_COMMAND);
				statement.setLong(1, mail.getMessageId());
				statement.executeUpdate();
				
				return true;
			} else {
				throw new SQLException("Inserting message into database returned an empty ResultSet!");
			}
		} catch (SQLException e) {
			e.printStackTrace();
			return false;
		} finally {
			try {
				if (statement != null) {
					statement.close();
				}
				if (connection != null) {
					connection.close();
					connection = null;
				}
				if (result != null) {
					result.close();
				}
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
	}