Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Internally what happens when Class.forName() is executed

 
Praveen palukuri
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
i know that Class.forName(...) loads driver if it is not loaded earlier. Shall any one explain what is the internal process going on when it is executed.

Thank YOu,
 
Annie Smith
Ranch Hand
Posts: 172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure how deep do you want to know. Go through the API, the JLS or finally take a look at the source code.
 
purushottaman dwarkanathan
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Basically after the Class.forName() internally

DriverManager.registerDriver() is called. This will look for the appropriate driver and registers it. The DriverManager class will maintain a list of the registered drivers.

I hope this helps.

Thanks,

Purushottaman
 
Sirish Kumar Gongal Reddy
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
1)What you said previously about Class.forName() is exactly correct.if come to the internals Class.forName won't create any memory for your driver(note that it won't create memory for your driver only for entair object it can) at the time your instantiation.when you are trying to use that driver then only it will create memory.So that we can use memory efficiently.
2)Generally Class.forName() takes String as a argument insted of passing your correct driver you can pass any string variable as a argument so that it won't take care about what you are passing at compile time when you try to run that program it will raise an runtime exception.
Hope that you got my point.
Regards,
G Sirish Reddy.,
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic