Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What to do about "no ocijdbc11 in java.library.path" SQL Developer error

I am trying to get create a TNS connection in SQL Developer on my mac laptop (OS X 10.9.5). I get this error no ocijdbc11 in java.library.path I googled around and found out that I need to install oracle's instant client. I found the instance client files here :

http://www.oracle.com/technetwork/topics/intel-macsoft-096467.html

The files are just zip files that you need to download and extract somewhere. Then I found the instructions that actually tell you what to do with the zip files here:

https://docs.oracle.com/cd/E11882_01/install.112/e38228/inst_task.htm#BABHEBIG

The instructions say that :

Set the DYLD_LIBRARY_PATH and the NLS_LANG environment variables to the full path of the instantclient_11_2 directory. For example, if you unzipped the Instant Client zip file in the /bin/oracle directory, then set the DYLD_LIBRARY_PATH environment variable to /bin/oracle/instantclient_11_2.

What the instructions do not tell me is HOW to set environment variables permanently and how to make the environment variables accessible to GUI tools like SQL developer.

Has anyone gotten SQL Developer to work with instantclient?

like image 622
Red Cricket Avatar asked Apr 17 '15 19:04

Red Cricket


People also ask

How do I fix error code ocijdbc11 in Java?

You can fix this error by adding ocijdbc11.dll in your PATH environment variable or into your java.library.path variable. If that DLL is not available in your system then download and install Oracle client like SQL Developer, which contains both thick and thin JDBC driver to connect to Oracle database.

What does error no ocijdbc10 in Java library path mean?

If you get java.lang.unsatisfiedlinkerror no ocijdbc10 in java.library.path means you are connecting to Oracle 10g database but the solution is same with the only difference in Oracle version difference. Let us know if you face any issue while connecting to Oracle database from Java and I will try to help you here.

Why Oracle driver is searching for DLLs in Java library?

If you look at the error you will find that Java is complaining that ocijdbc11 dll is not found in java.library.path. If you further look then you will say that Oracle Driver is using System.loadLibrary () method to load the native library, which explains why Java is searching for dll in java.library.path.

How to fix Oracle 11g cannot connect to Oracle Server Error?

If you install Oracle 11g in 64-bit Windows 7 machine then this native library can be found in C:\Programs\Oracle\ora11g\bin\ocijdbc11.dll folder. Now just add this folder to your PATH and run your program again, provided any other error you should be able to connect to Oracle server.


2 Answers

Based on the answer of @Alex Poole: In El Capitan when SIP is enabled, this doesn't seem to work, because the DYLD_LIBRARY_PATH environment variable doesn't get transferred to the environment that bash ./sqldeveloper starts (last line of the SQLDeveloper.app/Contents/MacOS/sqldeveloper.sh) .

Solution: instead of editing the file SQLDeveloper.app/Contents/MacOS/sqldeveloper.sh I edited the file SQLDeveloper.app/Contents/Resources/sqldeveloper/sqldeveloper/bin/sqldeveloper and added the export DYLD_LIBRARY_PATH=/path/to/instantclient line there.

#!/bin/bash

export DYLD_LIBRARY_PATH=/path/to/instantclient

#=============================================================================
#  Launcher for Oracle SQL Developer
#  Copyright (c) 2005, Oracle. All rights reserved.
#=============================================================================

...
like image 196
Auke Avatar answered Nov 15 '22 08:11

Auke


If you're comfortable editing files, you can set the library path in the internal startup script. I edited this through Terminal.app and vim, by going to:

cd <wherever SQL Developer was installed/unzipped>
cd SQLDeveloper.app/Contents/MacOS
cp -p sqldeveloper.sh sqldeveloper.sh.backup
chmod o+w sqldeveloper.sh
vim sqldeveloper.sh

The file is protected by default, so I'm changing it to be writable (and making a backup first, just in case). If you skip that step, with vim you can save it with :w! to save it anyway.

Alternatively find the SQLDeveloper application in Finder, right click, and choose 'Show Package Contents', then drill down to Contents->MacOS, right-click the sqldeveloper.sh file and choose 'Open With' and your favourite text editor - TextEdit will do. As the file is locked you will be prompted to unlock it at some point - maybe on open or first edit, but TextEdit will ask you if you want to unlock it when you save.

However you get into the file, you can then specify add a line to set/export DYLD_LIBRARY_PATH:

#!/bin/bash
# Next line added for TNS connections
export DYLD_LIBRARY_PATH=/path/to/instantclient
export JAVA_HOME=`/usr/libexec/java_home -v 1.7`
here="${0%/*}"
cd "${here}"
cd ../Resources/sqldeveloper/sqldeveloper/bin
bash ./sqldeveloper -clean >>/dev/null

... where /path/to/instantclient is your unzipped directory; in the quoted example above, that would be /bin/oracle/instantclient_11_2. Also note that this needs to be the 64-bit instant client; it will complain about the wrong architecture if you try to use the 32-bit version.

One the modified file has been saved, relaunch SQL Developer and your TNS connection should now work. If you want to be able to use a TNS alias you can also set/export a TNS_ADMIN variable that points to a directory containing a tnsnames.ora file.

like image 36
Alex Poole Avatar answered Nov 15 '22 10:11

Alex Poole