Quality factor multiple definitions
Yes - there is a link and we can start from the first definition and arrive at the second.
Example: Lossy capacitor (C||R)
(1) Max. Energy stored: W=0.5 * Vmax² * C
(2) Energy dissipated (loss): W_d=Vmax² * Pi / (R * 2Pi * f)
(3) Ratio W/W_d=Qc=R * 2Pi * f * C = R/(1/wC)
Comments:

Derivation of (1): Integral (one period) over {v(t) * i(t) * dt}
with i(t)=ic(t)=Cdv(t)/dt and v(t)=Vmax * sin wt;

Derivation of (2): Same integral with i(t)=ir(t)=v(t)/R .


(4) Extension to the parallel resonant circuit:
If we concentrate the inductive and capacitive losses in one single parallel loss resistor R we can calculate the complex impedance Z. The corresponding pole location in the s-plane allows us to find the pole frequency (no surprise) wp=1/LC and the corresponding pole quality factor Qp=R/(1/wpC). This is the same expression as given above under (3) for w=wp.
Finally, it was shown elsewhere that the pole quality factor Qp is identical to the quality factor Q=wr/delta(w) as defined for a second order bandpass (selectivity).