• Post Reply Bookmark Topic Watch Topic
  • New Topic

class.forname...working  RSS feed

 
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
 
Marshal
Posts: 57254
175
  • 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.
 
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.
 
Don't sweat petty things, or pet sweaty things. But cuddle this tiny ad:
The WEB SERVICES and JAX-RS Course
https://coderanch.com/t/690789/WEB-SERVICES-JAX-RS
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!