How does DriverManager knows which connection it shd return?
Kunaal A Trehan
Joined: Feb 04, 2004
I have been asked this question in an interview.It has 2 parts i)Can we load drivers for SQL Server and Oracle in one class? ii)If we can do the above operation,how will driver manager come to know which connection it shd return when u call DriverManager.getConnection();
This question may be silly for some Any info on this will be appreciated..
Your first question: think about how you explicitly load a driver: all you do is load and initialize the driver class. There is nothing in that operation which will stop you loading more than one driver.
Also look at the JavaDocs for DriverManager, and notice what common parameter the getConnection() methods always take. There is the answer to your second question.