aspose file tools*
The moose likes JDBC and the fly likes How does DriverManager knows which connection it shd return? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "How does DriverManager knows which connection it shd return?" Watch "How does DriverManager knows which connection it shd return?" New topic
Author

How does DriverManager knows which connection it shd return?

Kunaal A Trehan
Ranch Hand

Joined: Feb 04, 2004
Posts: 63
Hi

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..


Kunal
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

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.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Kunaal A Trehan
Ranch Hand

Joined: Feb 04, 2004
Posts: 63
Thnx alot
I got the answer
Its better to look in JavaDocs first and then post a msg on forum
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Originally posted by Kunal Verma:
Thnx alot
I got the answer
Its better to look in JavaDocs first and then post a msg on forum


Glad to hear it. The JavaDocs will usually be the quickest way to answer a question, but don't stop posting questions when you get stuck.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How does DriverManager knows which connection it shd return?