File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes loading JDBC driver 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 "loading JDBC driver" Watch "loading JDBC driver" New topic

loading JDBC driver

amit sanghai
Ranch Hand

Joined: Dec 05, 2000
Posts: 231
Why do we need to use Class.forName() to load a JDBC driver into the memory?
Is there any other method?
Can we use new operator to instantiate the Driver class.
gokul krishna

Joined: Jul 01, 2003
Posts: 2
Hi amit,
Actually class.forName is the JDBC API in which u can register ur driver in the memory to connect into the Database. Even u can register more than one driver also.
Apart from this, u can also register using the oracle driver using the DriverManager class.
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
By doing the above also u can register your driver.
Avi Abrami
Ranch Hand

Joined: Oct 11, 2000
Posts: 1141

You can also define a "system" property (using the '-D' command-line option), but I forget the name of it. I think it is "jdbc.driver". In any case, you can find details in the Getting Started Guide.
Good Luck,
David Gallardo

Joined: Jul 07, 2003
Posts: 18
Yes, you can instantiate the driver and register it as follows:
DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
Yet another way is to use the DataSource API.
[ August 02, 2003: Message edited by: David Gallardo ]

Co-author: "Eclipse in Action: A guide for the Java developer"<br />Author: "Java Oracle Database Development"
I agree. Here's the link:
subject: loading JDBC driver
jQuery in Action, 3rd edition