使用mssql2008和jdbc进行数据库连接

时间:2016-08-09 01:07:17

标签: sql-server-2008 jdbc eclipse-kepler

所以我设置了我的代码

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;
        }
    }

但是,当我尝试连接到数据库时,我得到以下例外情况。

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".

0 个答案:

没有答案