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 What Class.forName() actually does internally? 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 "What Class.forName() actually does internally?" Watch "What Class.forName() actually does internally?" New topic
Author

What Class.forName() actually does internally?

prithvi s zankat
Greenhorn

Joined: Jul 18, 2005
Posts: 12
Hi,
I still am not clear about the Class.forName(). I know that it load the Class defination. Why defination is required when we load driver and not the object of that class?
Shailesh Chandra
Ranch Hand

Joined: Aug 13, 2004
Posts: 1081

In JDBC by calling the method Class.forName. This explicitly loads the driver class. Since it does not depend on any external setup, this way of loading a driver is the recommended one for using the DriverManager framework. The following code loads the class acme.db.Driver:
Class.forName("Driver");

If Driver has been written so that loading it causes an instance to be created and also calls DriverManager.registerDriver with that instance as the parameter (as it should do), then it is in the DriverManager's list of drivers and available for creating a connection.


Shailesh


Gravitation cannot be held responsible for people falling in love ~ Albert Einstein
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: What Class.forName() actually does internally?
 
Similar Threads
JDBC, mysql connector/j, face a problem to connect mysql 5.1 and JSE.
Loading of Classes
Fundamental but do reply onthese defination
Confusion in Class.forName() :confused:
getContextClassLoader() problem