如何使用JDBC和SSL连接连接Sybase ASE?

时间:2019-06-26 20:34:14

标签: java ssl jdbc sybase-ase jconnect

我正在尝试使用JDBC驱动程序建立与Sybase ASE 16.0的SSL连接。在服务器上,通过交互式SQL,我可以使用SSL访问ASE服务器。我正在将Jconnect 4(jconn4.jar)和JDK 8与以下连接字符串一起使用:jdbc:sybase:Tds:host:port / dbname?ENABLE_SSL = true。使用keytool将服务器证书导入到Java应用程序信任库中。我已经完成了operator precedence的操作,但这无助于我纠正此问题。测试代码如下。

public IActionResult GeStudents(GraduationStatus selectedGraduationStatus) 
{
    var graduates = db.Graduated_Students.Where(t=> t.GraduationStatus == selectedGraduationStatus);
    return View(graduates.ToList());
}

我的JDBC代码抛出以下异常。 应该通过安全网络建立连接,但是面临以下错误。

try {
        Class.forName("com.sybase.jdbc4.jdbc.SybDriver");
        Connection con = DriverManager.getConnection(
                "jdbc:sybase:Tds:host:5000/master?ENABLE_SSL=TRUE", "sa",
                "password");
        System.out.println("*********Connected**********");
        Statement stmt = con.createStatement();
        ResultSet rs = stmt.executeQuery("select @@ssl_ciphersuite");
        int i = 1;
        while (rs.next()) {
            System.out.println("Row: " + i);
            System.out.println("ID: " + rs.getString(1).trim());
            System.out.println(" ");
            i = i + 1;
        }
        con.close();
    } catch (Exception e) {
        e.printStackTrace();
    }

我检查了Sybase日志,看到以下错误:

java.sql.SQLException: JZ00L: Login failed.  Examine the SQLWarnings chained to this exception for the reason(s).
    at com.sybase.jdbc4.jdbc.SybConnection.getAllExceptions(Unknown Source)
    at com.sybase.jdbc4.jdbc.SybConnection.handleSQLE(Unknown Source)
    at com.sybase.jdbc4.jdbc.SybConnection.a(Unknown Source)
    at com.sybase.jdbc4.jdbc.SybConnection.handleHAFailover(Unknown Source)
    at com.sybase.jdbc4.jdbc.SybConnection.<init>(Unknown Source)
    at com.sybase.jdbc4.jdbc.SybConnection.<init>(Unknown Source)
    at com.sybase.jdbc4.jdbc.SybDriver.connect(Unknown Source)
    at java.sql.DriverManager.getConnection(DriverManager.java:664)
    at java.sql.DriverManager.getConnection(DriverManager.java:247)
    at com.testing.Test.main(Test.java:41)

我浏览了多个Sybase文档,但是没有运气。任何帮助都感激不尽。在此先感谢!

0 个答案:

没有答案