2

I am trying to get Oracle SQL Developer to work in 16.04. I followed PhatHV's answer to this question, and the desktop app opens fine and appears correct, but when I try to connect to a database (and I know this should work because I've connected to the same database in Windows), an error window pops up saying

An error was encountered performing the requested operation:

no ocijdbc12 in java.library.path

Vendor code 0

Does anyone know what causes this error and how to fix it?

TallChuck
  • 289

2 Answers2

0

For me it only works when I set the LD_LIBRARY_PATH environment variable to the Instant Client directory, doing so in /etc/ld.so.conf.d/oracle.conf and running sudo ldconfig doesn't.

0

Okay, I have now managed (with some help) to fix this problem on two separate computers, but it's been long enough that I don't remember everything we did to fix it. I'll include at least what I remember, and may amend this answer later on. I don't understand everything under the hood, so I apologize if there are unnecessary steps. However, as I mentioned in the original question, I had followed another answer given by PhatHV, and I will not repeat here the steps found there. It is assumed that you have followed his tutorial before coming here.

Install the Oracle Instant Client

For SQL Developer version 4.2.0 I needed to get version 12.2.0.1.0 of the Instant Client. You can find the download here. Select the "Instant Client for Linux" that corresponds to your architecture (I have a 64 bit machine, so I opened the x86-64 option. Download the following 5 files (substituting version number and architecture where appropriate):

  • oracle-instantclient12.2-basic-12.2.0.1.0-1.x86-64.rpm
  • oracle-instantclient12.2-devel-12.2.0.1.0-1.x86-64.rpm
  • oracle-instantclient12.2-jdbc-12.2.0.1.0-1.x86-64.rpm
  • oracle-instantclient12.2-odbc-12.2.0.1.0-1.x86-64.rpm
  • oracle-instantclient12.2-sqlplus-12.2.0.1.0-1.x86-64.rpm

If you don't have it already, you will need to install a tool called alien:

sudo apt-get install alien

Navigate to your Downloads directory (or wherever you saved the files), and run sudo alien -i on each file to install it. We use alien becaues it first converts them to .deb before installing them. As a note, alien doesn't produce much output right away, so it may look like it's not doing anything, but I promise it is.

sudo alien -i oracle-instantclient12.2-basic-12.2.0.1.0-1.x86-64.rpm
sudo alien -i oracle-instantclient12.2-devel-12.2.0.1.0-1.x86-64.rpm
sudo alien -i oracle-instantclient12.2-jdbc-12.2.0.1.0-1.x86-64.rpm
sudo alien -i oracle-instantclient12.2-odbc-12.2.0.1.0-1.x86-64.rpm
sudo alien -i oracle-instantclient12.2-sqlplus-12.2.0.1.0-1.x86-64.rpm

Edit Profile and Environment Variables

You will need to be a root user for all of these commands. Run sudo su to login as root.

Edit /etc/profile.d/oracle.sh to contain the following:

export ORACLE_HOME=/usr/lib/oracle/12.2/client64
export TNS_ADMIN=/usr/lib/oracle/ora
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib

Note here the version number in the ORACLE_HOME variable. Again, mine is 12.2, but yours might be something else. It is also common to set TNS_ADMIN=$ORACLE_HOME/ora, but I chose not to so that my .ora files are not in a version-dependent directory (such as 12.2).

Edit /etc/ld.so.conf.d/oracle.conf to contain

/usr/lib/oracle/12.2/client64/lib/

Again, note the version number.

Finally, in /etc/environment

PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
JAVA_HOME="/usr/lib/jvm/default-java/"
CLASSPATH=/usr/lib/jvm/default-java/lib:/usr/lib/jvm/default-java/include:/usr/lib/oracle/12.2/client64/lib

Once you've finished editing all these files, run

ldconfig
source /etc/profile.d/oracle.sh
source /etc/environment

Hit <Ctrl> + D or type exit to revert to a regular user.

Add as a Third-Party Driver

I don't know if this step is strictly necessary, but it works on my computer. If you open up SQL Developer, you can navigate to Tools -> Preferences -> Database -> Third Party JDBC Drivers and click Add Entry. Open to /usr/lib/oracle/12.2/client64 and click on lib. It will hilight it, and then you can click select to add it to the list.

After this step you will need to close and re-open SQL Developer. Once you've done all that, hopefully you won't get any more errors.

TallChuck
  • 289