File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

what if I regiter more than one driver?

 
kumar jha
Greenhorn
Posts: 3
  • 0
  • 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: 2905
1
Java Spring Ubuntu
  • 0
  • 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
  • 0
  • 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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic