Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Class.forName()

 
aakash bhatt
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the significance of the code Class.forName() while doing a connection?

Thanks,
aakash
 
Rodney Cabahug
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Class.forName() will try to load the class that you specified as string argument. If the class that you specified cannot be found in the classpath, Class.forName() will throw a ClassNotFoundException.
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm thinking that you're curious about the significance of this code in the context of JDBC. So, I'm moving this to the JDBC forum...
 
Julian Kennedy
Ranch Hand
Posts: 823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It registers the JDBC driver. Check the API docs for java.sql.Driver and/or java.sql.DriverManager for more info.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic