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