Basic Logic of Database Connection