Howto: validate classpath specified by user when doing test connection
Joined: Aug 26, 2004
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?
Thanks in advance.
[removed urgent from subject] [ July 22, 2005: Message edited by: Jeanne Boyarsky ]
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 ]