JTDS ClassNotFoundException 异常

JTDS ClassNotFoundException

我已经厌倦了谷歌搜索这个错误。请帮我。 我发现建议将 jtds-1.3.1.jar 添加到 class 路径或编辑你的 web.xml.

请告诉我该怎么做? 我使用 Idea、Maven、Gwt 并希望连接到 MS SQL 2008 Express。

java.lang.ClassNotFoundException: net.sourceforge.jtds.jdbc.Drive
    at java.net.URLClassLoader.run(URLClassLoader.java:372)
    at java.net.URLClassLoader.run(URLClassLoader.java:361)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:260)

....... ....

http://maven.apache.org/maven-v4_0_0.xsd"> 4.0.0

<groupId>gr1</groupId>
<artifactId>art1</artifactId>
<version>1.0-SNAPSHOT</version>

<packaging>war</packaging>

<name>search</name>

<properties>
    <gwt.version>2.7.0</gwt.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <web.xml.path>src/main/webapp/WEB-INF/web.xml</web.xml.path>
</properties>


<dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>3.8.1</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.google.gwt</groupId>
        <artifactId>gwt-user</artifactId>
        <version>${gwt.version}</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>com.google.gwt</groupId>
        <artifactId>gwt-servlet</artifactId>
        <version>${gwt.version}</version>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.ow2.asm</groupId>
        <artifactId>asm</artifactId>
        <version>5.0.3</version>
    </dependency>
    <dependency>
        <groupId>com.cloudbees.thirdparty</groupId>
        <artifactId>vijava</artifactId>
        <version>5.5-beta</version>
    </dependency>
    <dependency>
        <groupId>net.sourceforge.jtds</groupId>
        <artifactId>jtds</artifactId>
        <version>1.3.1</version>
    </dependency>
</dependencies>

<build>
    <finalName>adsearch</finalName>
</build>

<profiles>
    <!-- LOCAL TOMCAT DEPLOY  -->
    <profile>
        <id>Local Tomcat</id>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.tomcat.maven</groupId>
                    <artifactId>tomcat7-maven-plugin</artifactId>
                    <version>2.2</version>
                    <configuration>
                        <server>localhost</server>
                        <url>http://localhost:8080/manager/text</url>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>gwt-maven-plugin</artifactId>
                    <version>${gwt.version}</version>
                    <executions>
                        <execution>
                            <goals>
                                <goal>compile</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>

            </plugins>
        </build>
    </profile>

    <!-- PRODUCTION TOMCAT DEPLOY  -->
    <profile>
        <id>Production Tomcat</id>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.tomcat.maven</groupId>
                    <artifactId>tomcat7-maven-plugin</artifactId>
                    <version>2.2</version>
                </plugin>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>gwt-maven-plugin</artifactId>
                    <version>${gwt.version}</version>
                    <executions>
                        <execution>
                            <goals>
                                <goal>compile</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>

            </plugins>
        </build>
    </profile>

</profiles>

当您执行 Class.forName(...)

时,请检查您指定的是 net.sourceforge.jtds.jdbc.Driver 而不是 net.sourceforge.jtds.jdbc.Drive