Energies of the ground and some excited states of on-centre donors in spherical quantum dots are calculated, within the effective mass approximation, as functions of the R dot radius and for different potential shapes. We propose an exact numerical solution for the radial Schrödinger equation in a quantum dot with any arbitrary spherical potential by using a trigonometric sweep method. An evident increase in the binding energy is found as the soft-edge-barrier potential model is considered. It is found that the binding energy increases as the dot size decreases up to a dot radius critical value and then, for R slightly smaller than , the impurity wave function spreads to the barrier region and the 3D character is rapidly restored. The properties of the shallow donors in a quantum dot with a double-step potential barrier and multiple barriers are analysed, and two peaks in the binding energy are found. Our results for the spherical-rectangular potential are in good agreement with previous calculations obtained using other methods.