Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Setting classpath to test connection to database

 
Sunil Aggarwal
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I need to the following:

1. Test connection to a database/datasource using the classpath specified by the user. The classpath will be an absolute path like c:\...where the jar will be located.

I have the some question regarding that:

a. I can't set classpath at runtime, can i?
b. How can I load jars at runtime to test connection and hence load the driver class?
c. Is it possible to set the classpath temporarily with the one given by user? I guess using command line "set classpath" will not help, right?
d. URLClassloader allows loading of jars but it accepts a URL as an argument and i assume i cant specify a location like "C:\.." in the URL.
Am i right?

Please help. Any quick suggestions would be highly appreciated.

Thanka and Regards.
 
Yilmaz Mete
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Regarding d) you can of course define a file , wrap it in a URL.

But what are you trying to achieve in general? sort of ambiguous.
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!