Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Load JDBC Driver via URLClassLoader

 
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I have a small problem with loading my JDBC driver. For a couple of reasons, I cannot put the jar(s) on the classpath, but in a configuration file. After reading this file, I create a URLClassLoader including all the jars that are listed in the config file. Then I call Class myDriverClass = Class.forName(<driverName>, true, myUrlClassLoader), which finds, loads and even instantiates the driver class trough the newInstance() method without the slightest problem. Only DriverManager.getConnection() keeps on throwing SQLExceptions telling me "No suitable driver" ...

Any ideas regarding how I can make the DriverManager know my driver?

Thanks for any advice,

Guido
 
Ranch Hand
Posts: 959
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This link might help you:
http://www.kfu.com/~nsayer/Java/dyn-jdbc.html
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic