#244 Class loading problem

open
nobody
General (151)
5
2005-09-17
2005-09-17
dev00980
No

Class.forName() throws ClassNotFoundException for a
loaded class in BeanShell:

How to recreate:
- Download a jar file (e.g hsqldb.jar from the HSQLDB
project @ SF.net)
- Run the BeanShell console
- add the jar file to class path:
addClassPath("hsqldb.jar");
- import all classes: import *;
- call Class.forName("org.hsqldb.jdbcDriver");

Exception thrown

java.lang.ClassNotFoundException: org.hsqldb.jdbcDriver

Discussion

  • Djangofan

    Djangofan - 2011-08-19

    Not sure if its the answer... its a hint to the answer. Only a beanshell developer would know if this is the answer: http://www.kfu.com/~nsayer/Java/dyn-jdbc.html

     
  • Djangofan

    Djangofan - 2011-08-19

    This doesnt work, but it seems that it should:
    try {
    Class driverClass = getClass( driver );
    if(driverClass != null) {
    Driver driver = driverClass.newInstance();
    if(driver != null) {
    DriverManager.registerDriver(driver);
    }
    }
    conn = DriverManager.getConnection(url+dbName,userName,password);

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks