This paper proposes a three-stage, end-to-end text-to-SQL framework that first identifies databases that match a user's query intent in a large-scale database environment. While existing text-to-SQL approaches directly translate natural language queries into SQL commands based on a specific database, our framework leverages LLM and prompt engineering to extract a set of rules from natural language queries. Based on these rules, we train a large-scale db_id prediction model, which incorporates a fine-tuned RoBERTa-based encoder, to predict the correct database identifier (db_id). Finally, we use a critique agent to correct errors in the generated SQL. Experimental results demonstrate that the proposed framework outperforms state-of-the-art models in terms of database intent prediction and SQL generation accuracy.