JTDS 1.3 connection issue with java8 x64

3.1k views Asked by At

I get the following error when trying to use jtds 1.3 + jdk1.8(64) on Windows 7.

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

Sample code here:

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 version:

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)

And here are tests I did:

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.

Any known issues regarding jtds1.3 + java8(64) on Windows?

1

There are 1 answers

0
Jeffery K On

jtds 1.3.1 has a known bug trying to use SSL when making a database connection, if run with java 8. It's documented here: http://sourceforge.net/p/jtds/bugs/725/ While it's marked as fixed, a new release of the code hasn't been packaged yet. We use the URL flag ssl=request when we connect with the jtds driver, so that way, if the server supports ssl, we'll make a ssl connection. When we used java 8, we got database connection failures, and this bug ended up being the reason. You can checkout the code, and build the driver yourself (as ugly as that is) but since it has already been over 1.5 years, and a new release has yet to be released, that would be the fastest viable fix.