aspose file tools
The moose likes JDBC and the fly likes regarding Drivers Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Reply Bookmark "regarding Drivers" Watch "regarding Drivers" New topic
Author

regarding Drivers

Krishna Bulusu
Ranch Hand

Joined: Jan 27, 2006
Posts: 32
hi,
i have one small doubt...
we will use Class.forName("driver"); to load the driver....

my doubt is can we load two drivers??
like

Class.forName("driver1");
Class.forName("driver2");

will the aboue code compiles and runs or any exception??

thanks in advance

regards,
krishna.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 35254
    
    7
You can have as many Class.forName statements in a program as you wish, just as you can use several different JDBC drivers in the same program. Mind you, Class.forName is a generic way to load classes, and not exclusively used for JDBC.


Android appsImageJ pluginsJava web charts
Krishna Bulusu
Ranch Hand

Joined: Jan 27, 2006
Posts: 32
thank u Ulf...

but in such case where i have loaded two drivers in the same programme...which one will be pramoted .....??
Martin Simons
Ranch Hand

Joined: Mar 02, 2006
Posts: 196
That depends on your connection url. jdbcracle would use the loaded
oracle driver. jdbc:mysql would use the loaded mysql driver. If you
load two drivers for the same db, then I believe it would use the first
one loaded for that connection url type.
[ May 29, 2006: Message edited by: Martin Simons ]
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: regarding Drivers
 
Similar Threads
Loading Oracle JDBC Driver
Loading Oracle JDBC Driver
Class.forName() -- doubt
Doubt on JDBC class.forname..
A doubt in JDBC