wood burning stoves 2.0*
The moose likes JDBC and the fly likes Setting classpath to test connection to database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Setting classpath to test connection to database" Watch "Setting classpath to test connection to database" New topic

Setting classpath to test connection to database

Sunil Aggarwal

Joined: Aug 26, 2004
Posts: 14
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

Joined: Dec 23, 2003
Posts: 28
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.
It is sorta covered in the JavaRanch Style Guide.
subject: Setting classpath to test connection to database
Similar Threads
oracle database and jsp
Howto: validate classpath specified by user when doing test connection
Java to Display Data from Database
ClassNotFound Exception using JWSDK for JSP