Fixed stack overflow when opening a new database connection.