This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes JDBC and the fly likes what if I regiter more  than one driver? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Databases » JDBC
Reply 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: 2896
    
    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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: what if I regiter more than one driver?
 
Similar Threads
Why use Class.forName() to load driver
Loading Oracle JDBC Driver
Loading Oracle JDBC Driver
How to connect MySQL DB from JSP?
Connection to MySQL