This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes JDBC and the fly likes How does JDBC work? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "How does JDBC work?" Watch "How does JDBC work?" New topic

How does JDBC work?

James Leong

Joined: Dec 18, 2002
Posts: 3
I was wondering how JDBC works? Currently, I do 2 things to get a Connection:
a. load the driver, i.e. Class.forName(driverName)
b. get a connection through a static method in DriverManager, i.e. DriverManager.getConnection(url, user, passwd);
In the case, when a few different jdbc drivers are loaded, i.e. we need access through different databases, how does the program arbitrate between which driver class to use? Is it through the url?
If so, is it true that when the driver class is loaded it registers the url that it will listen to the system?
vishwas bansal

Joined: Dec 19, 2002
Posts: 6
you are very correct ,class.forname actually register and instantiate the driver can have as much driver as you want.consider it to be a hashtable of drivers.when we give url it goes to check every driver class instance if it identifies the url and on success results the connection.
I agree. Here's the link:
subject: How does JDBC work?
Similar Threads
loading driver in JSP
Selection of Driver for Connection
Urgent: Driver class loaded but getting no suitable driver found exception
Class.forname and DriverManager
need help on dynamic loading of jdbc driver