See http://en.wikipedia.org/wiki/Heegner_number#Consecutive_primes

Here is a longer piece Rabinowitz published on the topic below

Rabinowitz showed, in 1913, that $x^2 + x + p$ represent the maximal number of consecutive primes if and only if $x^2 + x y + p y^2$ is the only (equivalence class of) positive binary quadratic form of its discriminant. This condition is called "class number one." For negative discriminants the set of such discriminants is finite, called Heegner numbers.

Note that if we take $x^2 + x + ab$ so that the constant term is composite, we get composite outcome both for $x=a$ and $x=b,$ so the thing quits early. In the terms of Rabinowitz, we would also have the form $a x^2 + x y + b y^2,$ which would be a distinct "class" in the same discriminant, thus violating class number one. So it all fits together. That is, it is "reduced" if $0 < a \leq b,$ and distinct from the principal form if also $a > 1.$

For binary forms, I particularly like Buell, here is his page about class number one: BUELL. He does everything in terms of binary forms, but he also gives the relationship with quadratic fields. Furthermore, he allows both positive and indefinite forms, finally he allows odd $b$ in $a x^2 + b x y + c y^2.$ Note that I have often answered MSE questions about ideals in quadratic fields with these techniques, which are, quite simply, easy. Plus he shows the right way to do Pell's equation and variants as algorithms, which people often seem to misunderstand. Here I mean Lagrange's method mostly.

EEDDIITT: I decided to figure out the easier direction of the Rabinowitz result in my own language. So, we begin with the principal form, $\langle 1,1,p \rangle$ with some prime $p \geq 3. $ It follows that $2p-4 \geq p-1$ and
$$ p-2 \geq \frac{p-1}{2}. $$
Now, suppose we have another, distinct, reduced form of the same discriminant,
$$ \langle a,b,c \rangle. $$ There is no loss of generality in demanding $b > 0.$ So reduced means $$ 1 \leq b \leq a \leq c $$ with $b$ odd, both $a,c \geq 2,$ and
$$ 4ac - b^2 = 4 p - 1. $$ As $b^2 \leq ac,$ we find $3 b^2 \leq 4p-1 $ and, as $p$ is positive,
$ b \leq p.$

Now, define $$ b = 2 \beta + 1 $$ or $ \beta = \frac{b-1}{2}. $ From earlier we have
$$ \beta \leq p-2. $$
However, from $4ac - b^2 = 4p-1$ we get $4ac+1 = b^2 + 4 p,$ then
$ 4ac + 1 = 4 \beta^2 + 4 \beta + 1 + 4 p, $ then $4ac = 4 \beta^2 + 4 \beta + 4 p, $ then
$$ ac = \beta^2 + \beta + p, $$
with $0 \leq \beta \leq p-2.$ That is, the presence of a second equivalence class of forms has forced $x^2 + x + p$ to represent a composite number ($ac$) with a small value $ x = \beta \leq p-2,$ thereby interrupting the supposed sequence of primes. $\bigcirc \bigcirc \bigcirc \bigcirc \bigcirc$

EEDDIITTEEDDIITT: I should point out that the discriminants in question must actually be field discriminants, certain things must be squarefree. If I start with $x^2 + x + 7,$ the related $x^2 + x y + 7 y^2$ of discriminant $-27$ is of class number one, but there is the imprimitive form $ \langle 3,3,3 \rangle $ with the same discriminant. Then, as above, we see that $x^2 + x + 7 = 9$ with $x=1 =(3-1)/2.$

[ Rabinowitz, G. “Eindeutigkeit der Zerlegung in Primzahlfaktoren in quadratischen Zahlkörpern.” *Proc. Fifth Internat. Congress Math.* (Cambridge) **1**, 418-421, 1913. ]

Edit October 30, 2013. Somebody asked at deleted question
Smallest positive integer $n$ s.t. f(n) = $n^2 + n + 41$ is composite?
about the other direction in Rabinowitz (1913), and a little fiddling revealed that I also know how to do that. We have a positive principal form $$ \langle 1,1,p \rangle $$ where $$ - \Delta = 4 p - 1 $$ is also prime. Otherwise there is a second genus unless $ - \Delta = 27 $ or $ - \Delta = 343 $ or similar prime power, which is a problem I am going to ignore; our discriminant is minus a prime, $ \Delta = 1- 4 p . $

We are interested in the possibility that $n^2 + n + p$ is composite for $0 \leq n \leq p-2.$ If so, let $q$ be the smallest prime that divides such a composite number. We have $n^2 + n + p \equiv 0 \pmod q.$ This means $(2n+1)^2 \equiv \Delta \pmod q,$ so we know $\Delta$ is a quadratic residue. Next $n^2 + n + p \leq (p-1)^2 + 1.$ So, the smallest prime factor is smaller than $p-1,$ and $q < p,$ so $q < - \Delta.$

Let's see, the two roots of $n^2 + n + p \pmod q$ add up to $q-1.$ One may confirm that if $m = q-1-n,$ then $m^2 + m + p \equiv 0 \pmod q.$ However, we cannot have $n = (q-1)/2$ with $n^2 + n + p \pmod q,$ because that implies $\Delta \equiv 0 \pmod q,$ and we were careful to make $- \Delta$ prime, with $q < - \Delta.$ Therefore there are two distinct values of $n \pmod q,$ the two values add to $q-1.$ As a result, there is a value of $n$ with $n^2 + n + p \equiv 0 \pmod q$ and $n < \frac{q-1}{2}.$

Using the change of variable matrix
$$
\left(
\begin{array}{cc}
1 & n \\
0 & 1
\end{array}\right)
$$
written on the right, we find that
$$ \langle 1,1,p \rangle \sim \langle 1,2n+1,qs \rangle $$
where $n^2 + n + p = q s,$ with $2n+1 < q$ and $q \leq s.$ As a result, the new form
$$ \langle q,2n+1,s \rangle $$
is of the same discriminant but is already reduced, and is therefore not equivalent to the principal form. Thus, the class number is larger than one.