what do i do if i get a uti?

never had one before let alone am sexually active. can you only get it by sex? what do i do if i were to get it?