Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes forum!
  • 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
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

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: 24204
44
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.
 
Your mind is under my control .... your will is now mine .... read this tiny ad
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic