Fix database connection bug