How can oxygen have three bonds?
Consider the auto-ionization of water :

$\ce{ 2H_2O-&gt;H_3O+ + OH-}$

The first oxygen has three bonds, the second only has one.

You can think of the reaction taking place by a lone pair on the oxygen of one water molecule ripping off the proton only of the hydrogen of another water molecule to form a covalent bond between them using just the lone pair. The electron of the hydrogen is left behind and stays with the oxygen of the other molecule.

If you calculate the formal charges on each oxygen you will see the first one has a positive charge and the second one has a negative. The formal charge is just the valence number of electrons minus the number of bonds minus non-bonding electrons (using the lewis structure) and is a useful book keeping method to think about where the electrons go/are and what are the most stable structures.

Formal Charge Calculation