JTDS ClassNotFoundException

时间:2015-06-30 10:26:10

标签: java sql-server maven intellij-idea jtds

我很累于谷歌搜索这个错误。请帮我。 我发现建议将jtds-1.3.1.jar添加到类路径或编辑你的web.xml。

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

java.lang.ClassNotFoundException: net.sourceforge.jtds.jdbc.Drive
    at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
    at java.net.URLClassLoader$1.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>

enter image description here

1 个答案:

答案 0 :(得分:1)

执行net.sourceforge.jtds.jdbc.Driver时检查您是否指定net.sourceforge.jtds.jdbc.Drive而不是Class.forName(...)