문제

I got this exception:

java.lang.ClassNotFoundException: net.sourceforge.jtds.jdbc.Driver

I use jtds-1.2.2. I tried add jar or add external jar. I also do:

    String driver = "net.sourceforge.jtds.jdbc.Driver";

    try {
        Class.forName(driver);
    } catch (ClassNotFoundException e) { 
        // TODO Auto-generated catch block
        e.printStackTrace();
    }  

I did the same in java project and everything works good. But doing this in jsf project I get this exception. Why ?

도움이 되었습니까?

해결책

The libraries used by a web application at runtime are all the jars placed in the WEB-INF/lib directory of the deployed webapp. Adding the library in the classpath used to compile the webapp doesn't make it automatically available at runtime.

If you're using Eclipse, just drop the jar in WebContent/WEB-INF/lib, and it will be automatically added to the build path (i.e. the classpath used to compile the app), and also be part of the deployed webapp, and thus be available at runtime.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top