• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Howto: validate classpath specified by user when doing test connection

 
Sunil Aggarwal
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic