File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes Why Class.forName? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
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
I agree. Here's the link:
subject: Why Class.forName?
It's not a secret anymore!