This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JDBC and the fly likes Regarding Class loading Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Regarding Class loading" Watch "Regarding Class loading" New topic
Author

Regarding Class loading

Smitha Amresh
Greenhorn

Joined: Jun 13, 2005
Posts: 6
Hi!!

What happens if weload a class twice..

class.forName("A");
class.forName("B");

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?

Thnaks
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: 15299
    
    6

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.

Cheers,
Rahul


Rahul Juneja
ThoughtClicks - http://techlabs.thoughtclicks.com
Shailesh Chandra
Ranch Hand

Joined: Aug 13, 2004
Posts: 1081

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
Greenhorn

Joined: Jun 13, 2005
Posts: 6
Hi Shailesh, Thanks for the information
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Regarding Class loading
 
Similar Threads
How to instanciate a class by name?
can you please explain the output of this program?
How Class.ForName() actually creates new object internally passed in argument ?
Class.forName()?
SQL Exception :general error