Fixed NPE caused by null servername when getting a database on null server (i.e. local)

Now testing the variable before using for null before working on it