Classpath Frustrations

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Classpath Frustrations

Michael Freeman
Why does the following beanhshell script generate a
"No suitable driver" exception when trying to obtain a
JDBC connection?

String path = "c:/javalibs/jtds_1.2/jtds-1.2.jar";
File f = new File(path);

ClassLoader ccl =
urls = new URL[] {f.toURL()};
ClassLoader urlc = new URLClassLoader(urls,ccl);

String driver = "net.sourceforge.jtds.jdbc.Driver";
String url = "jdbc:jtds:sqlserver://localhost/mydb";


Class clazz = getClass(driver);

import java.sql.*;

Connection c =

Since JDBC (as i understand it) uses the thread
context classloader and (i thought) i pointed
BeanShell to using that same class loader i would have
thought everyone would have been happy (the
class.newInstance works OK as expected for example)

I know i could put the JDBC driver in the -cp
classpath when i invoke BeanShell but for a variety of
reasons i need to make this run time discovery of JARs
technique work...

Can someone tell me what i am missing here?



Want to start your own business?
Learn how on Yahoo! Small Business.

Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
Beanshell-users mailing list
[hidden email]