It's not a secret anymore!
The moose likes JDBC and Relational Databases and the fly likes Regarding Class loading Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Regarding Class loading" Watch "Regarding Class loading" New topic

Regarding Class loading

Smitha Amresh

Joined: Jun 13, 2005
Posts: 6

What happens if weload a class twice..


Connection c= DriverManager.getConnection("dbname");

here AQ and B are jdbc drivers..
Now here connection c is connection to which driver? what happens here exactly?

Smitha Parika
Paul Bourdeaux
Ranch Hand

Joined: May 24, 2004
Posts: 783
I think this would be better posted in a mre relevant forum. For instance, JDBC or Java in General (Intermediate).

“Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.” - Rich Cook
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15302

Moving to JDBC...

GenRocket - Experts at Building Test Data
Rahul Juneja
Ranch Hand

Joined: Aug 03, 2002
Posts: 425
Making a Guess........

IT should point to B.


Rahul Juneja
ThoughtClicks -
Shailesh Chandra
Ranch Hand

Joined: Aug 13, 2004
Posts: 1082

Once the Driver classes have been loaded and registered with the DriverManager class, they are available for establishing a connection with a database. When a request for a connection is made with a call to the DriverManager.getConnection method, the DriverManager tests each driver in turn to see if it can establish a connection.

It may sometimes be the case that more than one JDBC driver is capable of connecting to a given URL. For example, when connecting to a given remote database, it might be possible to use a JDBC-ODBC bridge driver, a JDBC-to-generic-network-protocol driver, or a driver supplied by the database vendor. In such cases, the order in which the drivers are tested is significant because the DriverManager will use the first driver it finds that can successfully connect to the given URL.

First the DriverManager tries to use each driver in the order it was registered. (The drivers listed in jdbc.drivers are always registered first.) It will skip any drivers that are untrusted code unless they have been loaded from the same source as the code that is trying to open the connection.
Smitha Amresh

Joined: Jun 13, 2005
Posts: 6
Hi Shailesh, Thanks for the information
I agree. Here's the link:
subject: Regarding Class loading
It's not a secret anymore!