If R is a ring and J⊂R is an ideal, can R/J ever be a flat R-module? For algebraic geometers, the question is "can a closed immersion ever be flat?"

The answer is yes: take J=0. For a less trivial example, take R=R_{1}⊕R_{2} and J=R_{1}, then R/J is flat over R. Geometrically, this is the inclusion of a connected component, which is kind of cheating. If I add the hypotheses that R has no idempotents (i.e. Spec(R) is connected) and J≠0, can R/J ever be flat over R?

I think the answer is no, but I don't know how to prove it. Here's a failed attempt. Consider the exact sequence 0→J→R→R/J→0. When you tensor with R/J, you get

0→ J/J

^{2}→R/J→R/J→0

where the map R/J→R/J is the identity map. If J≠J^{2}, this sequence is not exact, contradicting flatness of R/J.

But sometimes it happens that J=J^{2}, like the case of the maximal ideal of the ring k[t^{q}| q∈**Q**_{>0}]. I can show that the quotient is not flat in that case (see this answer), but I had to do something clever.

I usually think about commutative rings, but if you have a non-commutative example, I'd love to see it.