  In this work the charm and bottom quark masses are determined from QCD moment
sum rules for the charmonium and upsilon systems. To illustrate the special
character of these sum rules when applied to Coulomb systems we first set up
and study the behaviour of the sum rules in quantum mechanics. In our analysis
we include both the results from nonrelativistic QCD and perturbation theory at
next-next-to-leading order. The moments are evaluated at different values of
q^2 which correspond to different relative influence among the theoretical
contributions. In the numerical analysis we obtain the masses by choosing
central values for all input parameters. The error is estimated from a
variation of these parameters. First, the analysis is performed in the pole
mass scheme. Second, we employ the potential-subtracted mass in intermediate
steps of the calculation to then infer the quark masses in the MS-scheme. Our
final results for the pole- and MS-masses are: M_c = 1.75 \pm 0.15 GeV,
m_c(m_c) = 1.19 \pm 0.11 GeV, M_b = 4.98 \pm 0.125 GeV and m_b(m_b) = 4.24 \pm
0.10 GeV.
