Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Class.forName() doubt

 
sridhar lakka
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
Thanks in advance.
In regular JDBC program we will write,
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").
According to my knowledge, which will regsiers the drivers and Loads the class, is it rite?
And, actually which will returns a "Class", but we are not taking return like,Class cl=Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"), then how java is allowing.
Please tell me.
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's perfectly legal to ignore the result of a method call. The call has side effects -namely, that the driver gets registered-, and those are important here.
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!