File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes DriverManager.registerDriver or class.forName Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "DriverManager.registerDriver or class.forName" Watch "DriverManager.registerDriver or class.forName" New topic
Author

DriverManager.registerDriver or class.forName

saikrishna cinux
Ranch Hand

Joined: Apr 16, 2005
Posts: 689
hello,
which one is preferable?

DiverManager.RegisterDriver("class");//compile time
class.forName("class");//loads the calss at Runtime



what to do?


A = HARDWORK B = LUCK/FATE If C=(A+B) then C=SUCCESSFUL IN LIFE else C=FAILURE IN LIFE
SCJP 1.4
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

From the API:

public static void registerDriver(Driver driver) throws SQLException

Registers the given driver with the DriverManager. A newly-loaded driver class should call the method registerDriver to make itself known to the DriverManager.

Therefore the DRiver should call registerDriver when it loads (via Class.forName()) therefore you should not call it yourself.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: DriverManager.registerDriver or class.forName
 
Similar Threads
JDBC, mysql connector/j, face a problem to connect mysql 5.1 and JSE.
Dynamically loading a class
Loading of Classes
How to instanciate a class by name?
what this method do in JDBC?