Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

class.forname...working

 
Kunal Choudhary
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic