Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How does DriverManager knows which connection it shd return?

 
Kunaal A Trehan
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Kunaal A Trehan
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thnx alot
I got the answer
Its better to look in JavaDocs first and then post a msg on forum
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic