Added a seperate connect method
Added checking for mysql server has went away