This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes JDBC and the fly likes Why Class.forName? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Why Class.forName?" Watch "Why Class.forName?" New topic

Why Class.forName?

Pavan Sambare

Joined: Aug 21, 2006
Posts: 23
When you load a JDBC driver you use Class.forName to load it. Any reasons why?
What I thought is that you can pass an externalized string to Class.forName and thus use any Driver at runtime.
Does it also have to do something with ClassLoader hierarchy?

SCJP 1.4 -- 98%<br />SCWCD 5 -- 97%
Paul Sturrock

Joined: Apr 14, 2004
Posts: 10336

Have a search through this forum. THis question gets asked a lot, so there will be loads of answers. Als ohave a read through our JDBCFaqs, these cover a lot of the basics of JDBC.

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
It is sorta covered in the JavaRanch Style Guide.
subject: Why Class.forName?