Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Class.forName()

 
Natraj Gudla
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic