Updated database connection logic.
Implemented database select method.