$\def\ZZ{\mathbb{Z}}$ Let $X$ be a complete toric variety. I will show that $H^2(X, \mathbb{Z}) \cong A^1(X, \mathbb{Z}) \cong \mathrm{Pic}(X)$. Since there are examples of complete toric $3$-folds with trivial $\mathrm{Pic}$, this shows that these toric varieties have trivial $H^2$. I rely heavily on the theory of Minkowski weights by Fulton and Sturmfels. See corollary 2.4 of that paper for the isomorphism $\mathrm{Pic}(X) \cong A^1(X)$ and example 5.6 for a toric 3-fold with trivial $\mathrm{Pic}$.

It is possible that if I understood mixed Hodge theory better, I could read this off immediately from the Fulton-Sturmfels paper. The last sentence of Section 1 says that, for $X$ a complete toric variety, $A^{\ast}(X) \otimes \mathbb{Q}$ is isomorphic to the appropriate weight space of $H^{2 \ast}(X)$, and maybe it is obvious to an expert that the other weight spaces of $H^2(X)$ vanish in our setting. But it isn't clear to me, so I will compute $H^2(X)$ explicitly and show that it matches with the description of $A^1(X)$ by Fulton and Sturmfels.

Let $\Sigma$ be a complete fan and $X$ the corresponding toric variety. I'll write $\Sigma^k$ for the set of cones in $\Sigma$ of codimension $k$. For $\rho$ a full dimensional cone of $\Sigma$, and $\sigma$ a codimension $1$ wall bounding $\sigma$, write $m_{\rho \sigma}$ for the minimal vector of the dual lattice which is perpendicular to $\sigma$ and positive on $\rho$.

Fulton and Sturmfels (Lemma 2.3) show that $A^1(X)$ is isomorphic to the functions $c: \Sigma^1 \to \ZZ$ which obey the following condition: Let $\tau$ be any cone of codimension $2$ and let $\sigma_1 \subset \rho_1 \supset \sigma_2 \supset \cdots \supset \sigma_t \subset \rho_t \supset \sigma_{t+1} = \sigma_1$ be the cones surrounding it, with $\rho_i$ of codimension $0$ and $\sigma_i$ of codimension $1$. Then we must have
$$\sum_i c(\sigma_i) m_{\rho_i \sigma_i} = 0.$$

I must now realize this result in cohomology. For any cone $\kappa$, let $U_{\kappa}$ be the corresponding affine open. So, if $\kappa \subset \lambda$ then $U_{\kappa}$ is an open subset of $U_{\lambda}$. We have an open cover $X = \bigcup_{\rho \in \Sigma_0} U_{\rho}$, indexed by the maximal cones of $\Sigma$. We now use what is basically the Meyer-Vietores spectral sequence (chapter 15 of Bott and Tu). I say basically, because I only want to use the intersection $U_{\rho_1} \cap U_{\rho_2}$ if $\rho_1$ and $\rho_2$ meet on a common wall. Since this is an MO answer not a paper, I'm going to be sloppy about this (but advertise two relevant questions 1 2.) We should get a spectral sequence which starts with $\bigoplus_{\alpha \in \Sigma^p} H^q(U_{\alpha_p})$, with the first page coming from the maps $H^q(U_{\alpha}) \to H^q(U_{\beta})$ whenever $\beta$ is a codimension one cone in $\alpha$.

For any $\alpha \in \Sigma^p$, we have $U_{\alpha} \cong (\mathbb{C}^{\ast})^p \times V_{\alpha}$ where $V_{\alpha}$ is Spec of a pointed semi-group ring. We can contract $V_{\alpha}$ onto its torus fixed point, so $H^q(U_{\alpha}) \cong H^q((S^1)^p) = \bigwedge^q \ZZ^p$. Explicitly, the $\ZZ^p$ in question is lattice vectors orthogonal to $\alpha$. So our first page has the form
$$\begin{matrix}
& & & & & & & \ddots \\
& & & & & & \ZZ^{\Sigma^3} & \cdots \\
& & & & \ZZ^{\Sigma^2} & \longrightarrow & \ZZ^{3 \times \Sigma^3} & \cdots \\
& & \ZZ^{\Sigma^1} & \longrightarrow & \ZZ^{2 \times \Sigma^2} & \longrightarrow & \ZZ^{3 \times \Sigma^3} & \cdots \\
\ZZ^{\Sigma^0} & \longrightarrow & \ZZ^{\Sigma^1} & \longrightarrow & \ZZ^{\Sigma^2} & \longrightarrow & \ZZ^{\Sigma^3} & \cdots \\
\end{matrix}$$
(You'll have to imagine those diagonal dots go the right way; MathJax doesn't seem to have the `\iddots`

command.)

The bottom row is the cohomology of a ball shaped $CW$-complex (the dual to the fan), so it wipes out on the next page. The map $\ZZ^{\Sigma^1} \to \ZZ^{2 \Sigma^2}$ exactly sends $\sigma \mapsto c(\sigma)$ to $\tau \mapsto \sum_i c(\sigma_i) m_{\rho_i \sigma_i}$ in our earlier notation. So the $(1,1)$ element on the next page is $A^1(X)$, and in general I believe the $(p,p)$ element is $A^p(X)$. (There is an issue I haven't checked carefully: Let $N$ be the lattice in which $\Sigma$ lives and $M$ the dual lattice. Let $\ZZ \alpha$ be the sublattice of $N$ spanned by $\alpha$ and let $\ZZ \alpha^{\perp}$ be the orthogonal sublattice of $M$. The spectral sequence naturally wants the map from the $(p,p)$ term to the $(p+1, p)$ term to go $\bigoplus_{\alpha \in \Sigma^p} \bigwedge^p \ZZ \alpha^{\perp} \to \bigoplus_{\beta \in \Sigma^{p+1}} \bigwedge^p \ZZ \beta^{\perp}.$ Fulton and Sturmfels work with $\bigoplus_{\alpha \in \Sigma^p} \ZZ \to \bigoplus_{\beta \in \Sigma^{p+1}} N/ \ZZ \beta$. That's the same thing up to choosing orientations of all the cones. For $p=1$, Fulton and Sturmfels work out the translation for you and you can see that it gives the right answer; I haven't done the analogous computation for $p>1$.)

So the next page has the form
$$\begin{matrix}
& & & & & \ddots \\
& & & & A^3(X) & \cdots \\
& & & A^2(X) & ? & \cdots \\
& & A^1(X) & ? & ? & \cdots \\
\ZZ & & & & & \cdots \\
\end{matrix}$$
with arrows going right $2$ and down $1$. We see that $H^2$ has stabilized at $A^1$, as promised.

anyhypersurface $X \subset \mathbb{P}^n$ with $n \geq 4$. Then by Lefschetz theorem on hyperplane sections the restriction map $$H^2(\mathbb{P}^n, \, \mathbf{Z}) \longrightarrow H^2(X, \, \mathbf{Z})$$ is an isomorphism. This implies $H^2(X, \, \mathbf{Z})= \mathbf{Z}$, that is $b_2(X)=1$. $\endgroup$ – Francesco Polizzi Jul 18 '14 at 9:31projectivevariety of dimension at least two, it seems to me that the hyperplane section (with respect to some embedding) gives a class in $H^2(X, \mathbf{Z})$. If $X$ isnormal, so that we can do classical intersection theory on $X$, I would say that such a class is non-zero, since it intersect positively all the subvarieties of complementary codimension. So it seems to me that, at least for normal projective varieties, necessarily $b_2(X) \geq 1$. I'm missing something? $\endgroup$ – Francesco Polizzi Jul 18 '14 at 10:20