*
The moose likes Beginning Java and the fly likes class.forname...working Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "class.forname...working" Watch "class.forname...working" New topic
Author

class.forname...working

Kunal Choudhary
Greenhorn

Joined: Feb 25, 2009
Posts: 14
Hey!!
can anybody please explain the actual working of the class.forname() method....esp with reference to the memory.....the concepts....also what happens when i say "class.forname(oracle.jdbc.driver);".....what happens internally
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37958
    
  22
The JVM (probably a ClassLoader) finds the class of that name and loads a Class<T> object into the memory used by the JVM. In the case of the JDBC connector classes, I believe there is a static initialiser block which initiates the connection to the database.
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
Whenever a class gets loaded, all of its static variables get initialized and static initializer blocks get fired. You know, 'static' applies on the class itself and has no instance dependence.
 
wood burning stoves
 
subject: class.forname...working
 
Similar Threads
Re:Class.forName()
Load the class thru class.forName() method
Loading Driver.
class.forName n statement interface
class.forname...working