dcsimg
Class.forName()
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Madhan_Prabahar
Posted On:   Friday, August 8, 2003 01:13 AM


What does the method Class.forName("DriverName") do exactly?
Cann't the driver be instantiated in a normal way like other objects?




Thanks
Madhan Prabahar

Re: Class.forName()

Posted By:   Zac_Jacobson  
Posted On:   Friday, August 8, 2003 10:44 AM

It loads a class with the name "DriverName". The driver can be instantiated in a normal way as an object if it has a public constructor, and the class will be loaded giving you the same effect.

However you don't necessarily know what that class will be at compile time, and you don't need an instantiation of the class, you just need the class itself to be loaded. Loading the class causes the class static blocks to be run, which register the driver with the jdbc classes, with the DriverManager I think.

About | Sitemap | Contact