Link to home
Start Free TrialLog in
Avatar of srikotesh
srikotesh

asked on

Connecting to oracle 19c through java application facing this issue java.sql.SQLException: Io exception: NL Exception

Hi Experts,
I am trying to connect oracle19c database through java application.
facing below error.

java.sql.SQLException: Io exception: NL Exception was generated

i am framing jdbc url like as below:
String jdbcurl = "jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=ValidHost)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME =ValidServicename)(SERVER = DEDICATED)))";

Open in new window

used ojdbc7.jar,java7 version
Please suggest what will be the issue.
Note:
i am able to connect with the same details to sql developer.
problem while connecting from application only.


ASKER CERTIFIED SOLUTION
Avatar of slightwv (䄆 Netminder)
slightwv (䄆 Netminder)

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of slightwv (䄆 Netminder)
slightwv (䄆 Netminder)

Well, I guess there might be an issue in your original connect string.

From Oracle Support:
      JDBC Connection to RAC Database Fails With "NL Exception Was Generated" (Doc ID 1205594.1)

Looks like Oracle is picky about spaces on either side of the '=' sign.


I still recommend the EZConneect format.
I still recommend the EZConneect format.
Sounds like a good idea. Obviously the more complex the string, the more error-prone it can be
Just to add:
you should stick to a newer version of ojdbc, like: https://www.oracle.com/database/technologies/appdev/jdbc-ucp-19c-downloads.html
(or at least to ojdbc8.jar)
Avatar of srikotesh

ASKER

Hi Experts/Alex,

Is ojdbc7.jar compatible with oracle19c?
Taken from: https://www.oracle.com/de/database/technologies/faq-jdbc.html

What is the recommended 19.x JDBC driver to be used with JDK11?     
      19.x version has
  (a) ojdbc8.jar (compiled with JDK8 (JDBC 4.2) and can be used with JDK9, JDK11) and
  (b) ojdbc10.jar (compiled with JDK10 (JDBC 4.3) and can be used with JDK11).
  If you are using JDK11 then, ojdbc8.jar is still a better choice as it includes all the 4.3 features but as Oracle extensions. Customers can use ojdbc10.jar only if they need JDBC 4.3 features available through standard Java SE.
  Example:
  ojdbc8.jar:
  Connection conn = DriverManager.getConnection(. . .);    // conn.beginRequest(); would fail because beginRequest is not in Java 8  ((OracleConnection)conn).beginRequest(); // succeeds because beginRequest is provided as an Oracle extension
  ojdbc10.jar:    Connection conn = DriverManager.getConnection(. . .);  conn.beginRequest(); // succeeds because beginRequest is in Java 10        ((OracleConnection)conn).beginRequest(); // succeeds because OracleConnection supports JDBC 4.3 (in Java 10) and beginRequest is part of JDBC 4.3
 

Hi Slightvw/Alex/Cehj,

I am able to connect successfully with the below format
jdbc:oracle:thin:@ValidHost:1521/ValidServicename

I am trying with the below syntax as well.but not connecting.if you have any ideas pls suggest on this as well
String jdbcurl = "jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=ValidHost)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME =ValidServicename)(SERVER = DEDICATED)))";

Open in new window

I am using java8,ojdbc8.jar

Not quite sure why you need to use that format but can you post literally what you have apart from changes to sensitive info (but NOT to whitespace)
You can use that format, but why not just make it a bit easier with (example):
jdbc:oracle:thin:scott/tiger@//myhost:1521/myservicename 

Open in new window

>>I am trying with the below syntax as well.but not connecting.if you have any ideas pls suggest on this as well

I posted the solution to this in my second post:  #a43293866

Looks like Oracle is picky about spaces on either side of the '=' sign.
Thanks. Now i am able to connect in both ways.