0

I am trying to Homebrew to install Oracle instant_client and sqlplus. Do the instructions discussed here still work:

How to install Oracle Instant Client on a Mac?

I have installed instant client and sqlplus using:

brew tap InstantClientTap/instantclient
brew install instantclient-basic
brew install instantclient-sqlplus

When I try to login to Oracle with sqlplus, I get the error:

ORA-12545: Connect failed because target host or object does not exist

The Oracle XE instance is running in a local Docker container. If I log in to the container, everything works fine. I can also connect to the database using SQLDeveloper. When connecting with sqlplus or oracledb in Nodejs (which uses instant client), I cannot connect.

When I log on to the Docker container, I can log on using sqlplus and the SYSTEM account:

Enter user-name: SYSTEM
Enter password: 
Last Successful login time: Wed Dec 21 2022 13:29:35 +00:00

Connected to:
Oracle Database 21c Express Edition Release 21.0.0.0.0 - Production
Version 21.3.0.0.0

SQL> 

When I try to log on from the OSX host using sqlplus using SYSTEM, I first get this error:

SQL*Plus: Release 19.0.0.0.0 - Production on Wed Dec 21 13:34:43 2022
Version 19.8.0.0.0

Copyright (c) 1982, 2020, Oracle.  All rights reserved.

Enter user-name: SYSTEM
Enter password: 
ERROR:
ORA-12162: TNS:net service name is incorrectly specified

I looked up this error and it mentioned having ORACLE_SID defined so I added exported ORACLE_SID=XE. I then got a different error:

SQL*Plus: Release 19.0.0.0.0 - Production on Wed Dec 21 13:40:25 2022
Version 19.8.0.0.0

Copyright (c) 1982, 2020, Oracle.  All rights reserved.

Enter user-name: SYSTEM
Enter password: 
ERROR:
ORA-12545: Connect failed because target host or object does not exist

Using a JDBC client I can connect using SYSTEM and the url jdbc:oracle:thin:@localhost:1521:XE with.

I can also connect via a nodejs program using nodejs-oracledb to connect the Oracle XE container.

In a nutshell, I can use sqlplus within the Docker terminal, I can connect from the OSX host using jdbc or nodejs oracledb but not with sqlplus.

jmc42
  • 359
  • 5
  • 22
  • On the host, setting ORACLE_SID won't work because you are using client libraries that are separate from the DB libraries, i.e you are 'remote' from the DB. You need to give a connection string. You should use the same connection string in SQL*Plus that you use in node-oracledb: something like `sqlplus -l system@localhost/XEPDB1` and then enter the password when prompted. – Christopher Jones Dec 22 '22 at 21:20

1 Answers1

0

Personally (but I'm biased) I install directly from Oracle's site using this script:

cd $HOME/Downloads
curl -O https://download.oracle.com/otn_software/mac/instantclient/198000/instantclient-basic-macos.x64-19.8.0.0.0dbru.dmg
hdiutil mount instantclient-basic-macos.x64-19.8.0.0.0dbru.dmg
/Volumes/instantclient-basic-macos.x64-19.8.0.0.0dbru/install_ic.sh
hdiutil unmount /Volumes/instantclient-basic-macos.x64-19.8.0.0.0dbru

Installing directly from Oracle means I know where the binaries are really coming from.

However the error you're getting doesn't seem like it is related to the Instant Client install - it's coming from the DB. I would guess you are using the wrong connection string. If you update your question with some more info, I can comment further. For reference, check out https://node-oracledb.readthedocs.io/en/latest/user_guide/connection_handling.html#jdbc-and-oracle-sql-developer-connection-strings

Christopher Jones
  • 9,449
  • 3
  • 24
  • 48