ocijdbc11 Not found in java.library.path

Vikora picture Vikora · Jul 20, 2017 · Viewed 14.5k times · Source

I inherited a small java utility from other developer -- just a couple of .java files and executable .jar.

I run java program by passes a connection string. Now I need to change the connection string to Oracle from jdbc:oracle:thin:<user>/<password>@host to jdbc:oracle:oci:<user>/<password>@host to start using thick instead of thin driver.

As a result I get the error: "ocijdbc11 (Not found in java.library.path)".

Here my questions:

  1. Is ocijdbc11 a part of ojdbc7.jar? Or what file do java need? ANSW: ocijdbc11 is a library: /oracle/client/o11r2/lib/libocijdbc11.so
  2. How can I see which paths java uses to find that ocijdbc11?

Just in case:

$ ls /oracle/client/o12r1/

assistants     diagnostics    jlib           oui            slax
bin            dmu            ldap           owm            sqlplus
cdata          has            lib            perl           srvm
cfgtoollogs    hs             network        plsql          ucp
clone          install        nls            precomp        usm
crs            instantclient  odbc           QOpatch        utl
css            inventory      OPatch         racg           wwg
cv             javavm         opmn           rdbms          xdk
dc_ocm         jdbc           oracore        relnotes
deinstall      jdk            oraInst.loc    root.sh

UPD I tried to use option -Djava.library.path=/oracle/client/o11r2 and got other error. But I still don't know how to use Oracle 12.1 instead of 11.2.

UPD2 I've changed environment paths to use Oracle 12 instead of 11. And now error looks like ocijdbc12 (Not found in java.library.path). The file /oracle/client/o12r1/lib/libocijdbc12.so exists.

I added /oracle/client/o11r2/lib to LD_LIBRARY_PATH -- the same error (ocijdbc12 (Not found in java.library.path)). I tried option -Djava.library.path=/oracle/client/o12r2/lib -- the same error. Could you please help me to fix it?

Answer

Jean de Lavarene picture Jean de Lavarene · Jul 20, 2017

ocijdbc11 is a native libary (.so or .dll) which you can download from the Oracle Instant Client. It's the layer that contains the JNI calls into the OCI. This library is needed if you want to use the thick driver. Be sure to install the version that matches your ojdbc jar (i.e. it looks like you're using the JDBC jar from 11.2 otherwise if you were using ojdbc jar from 12.1 the error would have complained about ocijdbc12 missing).