Let \(p\in [1,\infty ]\), \(q\in [1,\infty )\), \(s\in \mathbb {Z}_+:=\mathbb {N}\cup \{0\}\), \(\alpha \in \mathbb {R}\), and \(\beta \in (0,1)\). In this article, the authors first find a reasonable version \(\widetilde{I}_{\beta }\) of the (generalized) fractional integral \(I_{\beta }\) on the special John–Nirenberg–Campanato space via congruent cubes, \(JN_{(p,q,s)_{\alpha }}^{\textrm{con}}(\mathbb {R}^n)\), which coincides with the Campanato space \(\mathcal {C}_{\alpha ,q,s}(\mathbb {R}^n)\) when \(p=\infty \). To this end, the authors introduce the vanishing moments up to order s of \(I_{\beta }\). Then the authors prove that \(\widetilde{I}_{\beta }\) is bounded from \(JN_{(p,q,s)_\alpha }^{\textrm{con}}(\mathbb {R}^n)\) to \(JN_{(p,q,s)_{\alpha +\beta /n}}^{\textrm{con}}(\mathbb {R}^n)\) if and only if \(I_{\beta }\) has the vanishing moments up to order s. The obtained result is new even when \(p=\infty \) and \(s\in \mathbb {N}\), namely, the Campanato space. Moreover, the authors show that \(I_{\beta }\) can be extended to a unique continuous linear operator from the Hardy-kind space \(HK_{(p,q,s)_{\alpha +\beta /n}}^{\textrm{con}}(\mathbb {R}^n)\), the predual of \(JN_{(p',q',s)_{\alpha +\beta /n}}^{\textrm{con}}(\mathbb {R}^n)\) with \(\frac{1}{p}+\frac{1}{p'}=1=\frac{1}{q}+\frac{1}{q'}\), to \(HK_{(p,q,s)_{\alpha }}^{\textrm{con}}(\mathbb {R}^n)\) if and only if \(I_{\beta }\) has the vanishing moments up to order s. The proof of the latter boundedness strongly depends on the dual relation \((HK_{(p,q,s)_{\alpha }}^{\textrm{con}}(\mathbb {R}^n))^{*} =JN_{(p',q',s)_{\alpha }}^{\textrm{con}}(\mathbb {R}^n)\), the good properties of molecules of \(HK_{(p,q,s)_{\alpha }}^{\textrm{con}}(\mathbb {R}^n)\), and the crucial criterion for the boundedness of linear operators on \(HK_{(p,q,s)_{\alpha }}^{\textrm{con}}(\mathbb {R}^n)\).