How to connect Sybase ASE with JDBC and SSL connection?

3.5k Views Asked by At

I'm trying to establish an SSL connection to a Sybase ASE 16.0 using JDBC driver. On the server, through interactive SQL, I am able to access the ASE server with SSL. I am using Jconnect 4 (jconn4.jar) and JDK 8 with the following connection string: jdbc:sybase:Tds:host:port/dbname?ENABLE_SSL=true. Server certificate imported to the java application trust store using keytool. I have gone through the other question already asked here but it doesn't help me to rectify this problem. Test code is below.

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

My JDBC code throwing below exception. The connection should be established over the secure network but facing below error.

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)

I checked the Sybase log see the following error:

kernel  SSL or Crypto Error Message: 'The SSL handshake failed.  Root error: error:140760FC:SSL routines:SSL23_GET_CLIENT_HELLO:unknown protocol'.

I went through the multiple Sybase documentation but no luck. Any help will be much appreciated. Thanks in advance!!

0

There are 0 best solutions below