Polynomial and rational integrability of polynomial Hamiltonian systems