Let Ω⊂\rr2 be a bounded simply connected domain. We show that, for a fixed (every) p∈(1,\fz), the divergence equation divv=f is solvable in W01,p(Ω)2 for every f∈L0p(Ω), if and only if Ω is a John domain, if and only if the weighted Poincaré inequality ∫Ω∣u(x)−uΩ∣qdx≤C∫Ω∣∇u(x)∣q\dist(x,∂Ω)qdx holds for some (every) q∈[1,\fz). In higher dimensions similar results are proved under some additional assumptions on the domain in question.