0

So I have setup my code like so

public static Connection getConnection() {
        try {
            String dbURL = "jdbc:sqlserver://localhost:1433;databaseName=HRDB;
            String user = "sa";
            String pass = "r";

            Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
            Connection conn = DriverManager.getConnection(dbURL, user, pass);

            return conn;
        } catch (ClassNotFoundException c) {
            return null;
        } catch (SQLException s) {
            System.out.println(s.toString());
            return null;
        }
    }

However, when I try to connect to the database I get the following exceptions.

com.microsoft.sqlserver.jdbc.SQLServerException: The driver could not establish a secure connection to SQL Server by using Secure Sockets Layer (SSL) encryption. Error: "java.lang.RuntimeException: Could not generate DH keypair".
Rabin
  • 1,563
  • 4
  • 20
  • 44
  • Can you post the full stacktrace? – N00b Pr0grammer Aug 09 '16 at 06:30
  • You might want to take a look at the following question for some information - http://stackoverflow.com/questions/6851461/java-why-does-ssl-handshake-give-could-not-generate-dh-keypair-exception – N00b Pr0grammer Aug 09 '16 at 06:32
  • It turns out that this issue is with Windows 10 not with anyone of the above. – Rabin Aug 21 '16 at 10:03
  • Can you please let me and the others know on how have you identified it? May be edit your question to add your answer or answer your own question, so that it is helpful for the others too! – N00b Pr0grammer Aug 22 '16 at 03:11

0 Answers0