I'm doing a Proof-of-Concept (PoC) Java reporting project in which I'm connecting to a SSL-enabled Oracle database from my workstation, using JDBC Thin driver. As the database is SSL-enabled, I added all the required certificates into a Oracle Wallet and provided its location in the Java code. The certs were also added cacert of the JRE. Java code excerpt -
try { Class.forName("oracle.jdbc.driver.OracleDriver"); } catch (ClassNotFoundException e) { System.out.println("ERROR: Oracle JDBC Driver not found"); e.printStackTrace(); return; } System.out.println("Oracle JDBC Driver Registered!"); Connection connection = null; String oracleURL = "jdbc:oracle:thin:@(DESCRIPTION(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCPS)(HOST=<hostname>)(PORT=2484)))(CONNECT_DATA=(SERVICE_NAME=<service>)))"; // Provide user ID, password for schema Properties props = new Properties(); props.setProperty("user", "<user id>"); props.setProperty("password", "<password>"); // Setting properties for SSL props.setProperty("oracle.net.ssl_cipher_suites", "(ssl_rsa_export_with_rc4_40_md5, ssl_rsa_export_with_des40_cbc_sha, SSL_DH_anon_WITH_3DES_EDE_CBC_SHA, SSL_DH_anon_WITH_RC4_128_MD5,SSL_DH_anon_WITH_DES_CBC_SHA)"); props.setProperty("oracle.net.ssl_client_authentication", "false"); props.setProperty("oracle.net.ssl_version", "3.0"); props.setProperty("oracle.net.encryption_client", "REJECTED"); props.setProperty("oracle.net.crypto_checksum_client", "REJECTED"); props.setProperty("javax.net.ssl.keyStore", "C:\\APP\\ORACLE\\product\\11.2.0\\client_1\\ewallet.p12"); props.setProperty("javax.net.ssl.keyStoreType","PKCS12"); props.setProperty("javax.net.ssl.keyStorePassword","Password1"); try { connection = DriverManager.getConnection(oracleURL, props); } catch (SQLException e) { System.out.println("Connection Failed! Check output console"); System.out.println("Error code: " + e.getErrorCode()); System.out.println("SQL State: " + e.getSQLState()); e.printStackTrace(); return; }I'm able to compile the program and also run it using the following -
java -cp z:\jdk1.7.0_13\bin\ojdbc14.jar;z:\jdk1.7.0_13\bin OracleConnCheckwhere:
- z:\jdk1.7.0_13\bin\ojdbc14.jar - location of ojdbc14.jar
- z:\jdk1.7.0_13\bin - Java classpath
- OracleConnCheck - Java class
But I always encounter IO error accompanied with NL exception or SO exception. I checked out the Oracle and few articles related to the same exception in here but none addressed my exact problem. Could someone help? Thanks!
Edit: Adding the stacktrace -
Oracle JDBC Driver Registered!
Connection Failed! Check output console
Error code: 17002
SQL State: null
java.sql.SQLException: Io exception: NL Exception was generated at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:113) at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:147) at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:257) at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:389) at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:454) at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:165) at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:35) at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:802) at java.sql.DriverManager.getConnection(DriverManager.java:579) at java.sql.DriverManager.getConnection(DriverManager.java:190) at OracleConnCheck.establishConnection(OracleConnCheck.java:51) at OracleConnCheck.main(OracleConnCheck.java:72)
------- The End ------- 3 2 Answers
Make sure you use the latest 12.1.0.2 JDBC drivers. You can download from OTN. Also, you need to include osdt_core.jar and osdt_cert.jar.
Refer to SSL with Oracle JDBC whitepaper for more details.
1"NL Exception was generated" indicates that there is a format error in the connection string. In your case you are missing = after DESCRIPTION.