This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

what if I regiter more than one driver?

 
kumar jha
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We can register more than drvers using Class.forName("stringDriver1"), Class.forName("stringDriver2") and Class.forName("stringDriver3").
So which driver is used when we try to get a connection object, say, DriverManager.getConnection() ?
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
kumar jha wrote:We can register more than drvers using Class.forName("stringDriver1"), Class.forName("stringDriver2") and Class.forName("stringDriver3").
So which driver is used when we try to get a connection object, say, DriverManager.getConnection() ?


This explains itself. DriverManager#getConnection(String url)

And Welcome to JavaRanch
 
Balu Sadhasivam
Ranch Hand
Posts: 874
Android Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Kumar ,

It lies with the DriverManager decision. It chooses the appropriate correct driver from the loaded drivers using the connection string.

Connection String usually contains the type of database it uses and DriverManger takes care of using the correct driver.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic