0
我試圖用JTDS時,遇到下列錯誤1.3 + jdk1.8(64)在Windows 7JTDS 1.3連接問題
Exception in thread "main" java.lang.RuntimeException: Error initializing DESEngine
at net.sourceforge.jtds.util.DESEngine.init(DESEngine.java:76)
at net.sourceforge.jtds.util.DESEngine.<init>(DESEngine.java:51)
at net.sourceforge.jtds.jdbc.NtlmAuth.answerLmChallenge(NtlmAuth.java:52)
at net.sourceforge.jtds.jdbc.TdsCore.sendNtlmChallengeResponse(TdsCore.java:2179)
at net.sourceforge.jtds.jdbc.TdsCore.login(TdsCore.java:613)
at net.sourceforge.jtds.jdbc.JtdsConnection.<init>(JtdsConnection.java:369)
at net.sourceforge.jtds.jdbc.Driver.connect(Driver.java:183)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at test4.Test4.main(Test4.java:15)
Caused by: java.security.NoSuchAlgorithmException: DES SecretKeyFactory not available
at javax.crypto.SecretKeyFactory.<init>(SecretKeyFactory.java:122)
at javax.crypto.SecretKeyFactory.getInstance(SecretKeyFactory.java:160)
at net.sourceforge.jtds.util.DESEngine.init(DESEngine.java:69)
... 9 more
示例代碼瀏覽:
public static void main(String[] args) throws Exception {
String url = "jdbc:jtds:sqlserver://server:1433/db1;domain=dm1";
String user = "user";
String pwd = "password";
Class.forName("net.sourceforge.jtds.jdbc.Driver");
Connection cn = DriverManager.getConnection(url, user, pwd);
System.out.println("connected!");
}
Java版本:
C:\Program Files\Java\jdk1.8.0_40\bin>java -version
java version "1.8.0_40"
Java(TM) SE Runtime Environment (build 1.8.0_40-b26)
Java HotSpot(TM) 64-Bit Server VM (build 25.40-b25, mixed mode)
這裏是測試我所做的:
jtds-1.3(1.3.1)
Windows7 + jdk1.7.79 (32) works
Windows7 + jdk1.7.79 (64) works
Windows7 + jdk1.8.40 (32) works
Windows7 + jdk1.8.40 (64) NOT working
RedHat6.6 + jdk1.7.79 (64) works
RedHat6.6 + jdk1.8.40 (64) works
jtds-1.2.8:
works on any combination of system above.
有關Windows上jtds1.3 + java8(64)的任何已知問題?
jtds 1.3.1 + jdk 1.8.0_45 x64在Windows 8.1上對我來說工作正常(Window 7 x64和Windows 8 x64之間應該沒有任何區別,因爲jdk對於兩者都是相同的)。根據[javadoc](http://docs.oracle.com/javase/7/docs/api/javax/crypto/SecretKeyFactory.html),必須提供DES。也許值得用jdk 1.8.0u45試試看能否解決你的問題。 – assylias
謝謝,它適用於1.80_45 x64。 – fivelements