GeeCON Prague 2014*
The moose likes JDBC and the fly likes Howto: validate classpath specified by user when doing test connection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Databases » JDBC
Bookmark "Howto: validate classpath specified by user when doing test connection" Watch "Howto: validate classpath specified by user when doing test connection" New topic
Author

Howto: validate classpath specified by user when doing test connection

Sunil Aggarwal
Greenhorn

Joined: Aug 26, 2004
Posts: 14
Hi All,

I need to do a test connection when the user has specfied username, passwros, url etc. While using this i can test the connection but
can someone please tell me how can i validate the CLASSPATH also entered by the user. Can i possibly temorarily set the classpath to what user has specified and test the connection?

Please help!

Thanks in advance.

Sunil.

[removed urgent from subject]
[ July 22, 2005: Message edited by: Jeanne Boyarsky ]
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

First: EaseUp.

I am guessing you need to know if the driver class you are letting the user define is in the classpath so they can connect using the JDBC URL you also let them supply? In which case there are methods available in java.lang.ClassLoader - if you can load a class it is on the classpath. Alternatively you could get the classpath from the System properties and use java.io.* to see if the files named in the classpath exist (assuming the user explicitly includes a jar file rather thna just a directory).

You can't set the classpath at runtime, but you can use a URLClassLoader to load jars and classes at runtime, which amounts to the same thing.
[ July 22, 2005: Message edited by: Paul Sturrock ]

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
 
GeeCON Prague 2014
 
subject: Howto: validate classpath specified by user when doing test connection