Connects to database.