Cope better with invalid inputs like empty strings.
Server now has a chance of reacting if the MySQL server is unavailable.