Example 3 Let $A=\left\{x \mid x^{2}+p x+15=0\right\}, B=\left\{x \mid x^{2}-5 x+q=0\right\}$, and $A \cap$ $B=\{3\}$, find the values of $p$, $q$, and $A \cup B$.
Solution: According to the problem, $3 \in A, 3 \in B$, so $3^{2}+3 p+15=0, 3^{2}-5 \times 3+q=0$, we get $p=-8, q=6$, thus $A=\{3,5\}, B=\{3,2\}$, so $A \cup B=\{2,3,5\}$.

Solution Guide: In this example, we need to determine the values of the parameters based on one root of a quadratic equation, and then solve the equation to find the elements of the set. From another perspective, we can also use "Vieta's formulas" to first find the elements of the set and then determine the parameter values.