File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Class.forName() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Class.forName()" Watch "Class.forName()" New topic
Author

Class.forName()

Natraj Gudla
Ranch Hand

Joined: Feb 09, 2003
Posts: 34
Hi,
When i call Class.forName("drivername"),Here where does java pick up the class name from , is it by default the current directory , or does it search it in the classpath?.
and i have a problem that a user will give me the path to the driver and the driver name from the GUI in an application and i have to get the connection to the database using the driver...In this case how do i load the driver when i come to know abt the location of the driver at runtime?.
can any one help me?.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24166
    
  30

When i call Class.forName("drivername"),Here where does java pick up the class name from , is it by default the current directory , or does it search it in the classpath?.

It looks in the class path.
and i have a problem that a user will give me the path to the driver and the driver name from the GUI in an application and i have to get the connection to the database using the driver...In this case how do i load the driver when i come to know abt the location of the driver at runtime?.

The simplest way to do this would probably be to write a custom class loader which lets you extend the classpath at runtime.


[Jess in Action][AskingGoodQuestions]
 
Consider Paul's rocket mass heater.
 
subject: Class.forName()
 
Similar Threads
jdbc
Loading jdbc driver
loading driver in JSP
Class.forName
help needed !!!