aspose file tools*
The moose likes JDBC and the fly likes what if I regiter more  than one driver? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "what if I regiter more  than one driver?" Watch "what if I regiter more  than one driver?" New topic
Author

what if I regiter more than one driver?

kumar jha
Greenhorn

Joined: Jan 31, 2009
Posts: 3
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

Joined: Feb 19, 2008
Posts: 2902
    
    1

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


[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
Balu Sadhasivam
Ranch Hand

Joined: Jan 01, 2009
Posts: 874


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.
 
 
subject: what if I regiter more than one driver?