嘗試使用到Teradata的JDBC連接。我在Linux中編譯時加載了tdgssconfig.jar和terajdbc4.jar文件,並使用javac將它們添加到類路徑中。但在編譯時我仍然遇到ClassnotFoundException。Teradata和JDBC驅動程序 - classnotfoundexception ...但它的存在?
我在一段時間內沒有用過java,但是我已經在網上搜索過了,它看起來應該可以工作。
簡單代碼:
import java.sql.*;
class TDtest {
public static void main(String[] args) {
System.out.println(classpath);
Class.forName("com.teradata.jdbc.TeraDriver");
}
}
* .jar文件肯定是有:
[[email protected] java]# ls -l /home/user1/test/java/libs/*
-rwxrwxrwx 1 user1 user1 2405 Oct 26 12:00 /home/user1/test/java/libs/tdgssconfig.jar
-rwxrwxrwx 1 user1 user1 873860 Oct 26 12:00 /home/user1/test/java/libs/terajdbc4.jar
詳細的錯誤日誌 - 它看起來像類路徑是正確的,我說:
javac -verbose -cp ".:/home/user1/test/java/libs/tdgssconfig.jar:/home/user1/test/java/libs/terajdbc4.jar" TDtest.java
[parsing started TDtest.java]
[parsing completed 21ms]
[search path for source files: .,/home/user1/test/java/libs/tdgssconfig.jar,/home/user1/test/java/libs/terajdbc4.jar]
[search path for class files: /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre/lib/resources.jar,/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre/lib/rt.jar,/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre/lib/sunrsasign.jar,/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre/lib/jsse.jar,/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre/lib/jce.jar,/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre/lib/charsets.jar,/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre/classes,/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre/lib/ext/dnsns.jar,/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre/lib/ext/sunpkcs11.jar,/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre/lib/ext/localedata.jar,/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre/lib/ext/gnome-java-bridge.jar,/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre/lib/ext/sunjce_provider.jar,.,/home/user1/test/java/libs/tdgssconfig.jar,/home/user1/test/java/libs/terajdbc4.jar]
[loading java/lang/Object.class(java/lang:Object.class)]
[loading java/lang/String.class(java/lang:String.class)]
[checking TDtest]
[loading java/lang/Class.class(java/lang:Class.class)]
[loading java/lang/Error.class(java/lang:Error.class)]
[loading java/lang/ClassNotFoundException.class(java/lang:ClassNotFoundException.class)]
[loading java/lang/Exception.class(java/lang:Exception.class)]
[loading java/lang/Throwable.class(java/lang:Throwable.class)]
[loading java/lang/RuntimeException.class(java/lang:RuntimeException.class)]
TDtest.java:4: unreported exception java.lang.ClassNotFoundException; must be caught or declared to be thrown
Class.forName("com.teradata.jdbc.TeraDriver");
我已經嘗試瞭解Jdbc jar的jar,他們肯定有com/teradata/jdbc/TeraDriver.class。
我不知所措。任何想法我做錯了什麼?
非常感謝!自從我完成java之後,它已經很久了。 – rfusca