# How were the first molecular formulas determined?

How were molecular formulas determined before spectroscopy and spectronomy? I know that John Dalton thought that the formula of water was "HO" but we now know it to be "H2O." How did Dalton even know that water had hydrogen and oxygen in the first place?