My Oracle Support Banner

java.sql.SQLException: Io exception: The Network Adapter could not establish the connection When Oracle JDBC is used with SSL (Doc ID 464268.1)

Last updated on SEPTEMBER 26, 2019

Applies to:

JDBC - Version 10.2.0.3 and later
Information in this document applies to any platform.

Symptoms

Problem

On 10.2.0.3 in Production:
There is an installation of Advanced Security, configured a wallet, created a self-signed cert and imported it into the wallet. The tnsnames.ora, listener.ora and sqlnet.ora have been configured. The listener comes up and it is listening for connections on 1522. The tnsping command to the database over 1522 is working.

The listener.ora is as follows:

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC) (KEY = EXTPROC1))
      (ADDRESS = (PROTOCOL = TCP) (HOST = <HOST>)(PORT = 1521))
      (ADDRESS = (PROTOCOL = TCPS)(HOST = <HOST>)(PORT = 1522))
    )
  )

WALLET_LOCATION =
  (SOURCE=(METHOD=FILE)
          (METHOD_DATA=(DIRECTORY=/u01/app/oracle/product/db/10203/network/admin/))
  )
SSL_CLIENT_AUTHENTICATION=FALSE



The sqlnet.ora is as follows:

NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)

SQLNET.WALLET_OVERRIDE = TRUE
WALLET_LOCATION =
  (SOURCE=
    (METHOD = FILE)
    (METHOD_DATA =
      (DIRECTORY=/u01/app/oracle/product/db/10203/network/admin/)
    )
  )
SSL_CLIENT_AUTHENTICATION=FALSE



But, when the following section of code is run:

import java.security.Security;
  
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
    
import java.util.Properties;
    
public class TestSSL3
{
    
  public static void main(String[] argv) throws Exception
  {
    try
    {
      DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
      String url = "jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)" +
                   "(HOST=<HOST>t)" +
                   "(PORT=1522))(CONNECT_DATA=(SERVICE_NAME=<SERVICE_NAME>)))";
      Properties props = new Properties();
      props.setProperty("user", "<USERNAME>");
      props.setProperty("password", "<PASSWORD>");
      props.setProperty("oracle.net.ssl_cipher_suites",
                        "(SSL_DH_anon_WITH_3DES_EDE_CBC_SHA,
                          SSL_DH_anon_WITH_RC4_128_MD5,
                          SSL_DH_anon_WITH_DES_CBC_SHA)");
   
      // Set the wallet location
      props.setProperty("oracle.net.wallet_location",
              "(SOURCE=(METHOD=file)(METHOD_DATA=" +
              "(DIRECTORY=/u01/app/oracle/product/db/10203/network/admin)))");
      props.setProperty("oracle.net.ssl_client_authentication", "false");
      Connection conn = DriverManager.getConnection(url,props);
      Statement stmt = conn.createStatement();
      ResultSet rset = stmt.executeQuery(
                        "select 'Hello Thin driver SSL tester ' from dual");
      while (rset.next())
        System.out.println(rset.getString(1));
      rset.close();
      stmt.close();
      conn.close();
    }
    catch (SQLException sqle)
    {
      sqle.printStackTrace();
    }
  }
}



the following error is reported:

Exception in thread "main" java.sql.SQLException: Io exception: The Network Adapter could not
establish the connection
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:111)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:145)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:254)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:386)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:438)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:164)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:34)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:752)
at java.sql.DriverManager.getConnection(DriverManager.java:512)
at java.sql.DriverManager.getConnection(DriverManager.java:140)
at TestSSL.main(TestSSL.java:33)

Changes

 

Cause

To view full details, sign in with your My Oracle Support account.

Don't have a My Oracle Support account? Click to get started!


In this Document
Symptoms
 Problem
Changes
Cause
Solution
 To implement the solution, please execute the following steps

My Oracle Support provides customers with access to over a million knowledge articles and a vibrant support community of peers and Oracle experts.