This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
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.