• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Class.forName()

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?.
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic