5

I am trying to connect to an oracle database using oracle sqlplus instant client using tnsnames.ora. But getting this error: ORA-12162: TNS:net service name is incorrectly specified.

I have following environmental value set up :

DYLD_LIBRARY_PATH,TNS_ADMIN, ORACLE_HOME

The location of sqlplus is added to the PATH Variable. My instantclient10_2 deploying is located at ~/Library/oracle direcoty. The oracle folder has all the access to the user.

I am able to connect with TNS using oracle SqlDeveloper. Please help me resolve this issue.

OS Version:- Mac OS X 10.7.2 (Lion)

Mat
  • 202,337
  • 40
  • 393
  • 406
Omanand
  • 51
  • 1
  • 1
  • 2
  • Oracle SQLDeveloper comes with its own JDBC client... that has nothing to do with the instant client you installed... please provide more information... – Yahia Nov 27 '11 at 15:34
  • Please post the relevant part of the `tnsnames.ora`, and the way you are starting sqlplus. – Mat Nov 27 '11 at 15:35
  • Following are the sample tns entry in my tnsnames.ora:-VPN2TEST= (DESCRIPTION=(ADDRESS_LIST= (ADDRESS=(HOST=${host1})(PORT=1699)(PROTOCOL=TCP)) (ADDRESS=(HOST=${host2})(PORT=1699)(PROTOCOL=TCP))) (CONNECT_DATA=(SERVICE_NAME=vpn2test.fiberlink.com))) -Using following commands to connect with sqlplus >sqlplus user/passwd@vpn2test – Omanand Dec 02 '11 at 09:21
  • I had a similar issue and solved adding a sqlnet.ora to my oracle (in my case 12.1) with the following contents: NAMES.DIRECTORY_PATH = (TNSNAMES). In my environment, it's located at /usr/lib/oracle/12.1/client64/network/admin/sqlnet.ora – Arthur Accioly Oct 05 '16 at 22:52

2 Answers2

2
set ORACLE_SID=YOUR_SID_IN_tnsnames.ora
export ORACLE_SID
Devraj Gadhavi
  • 3,541
  • 3
  • 38
  • 67
phray2002
  • 425
  • 4
  • 9
0

I assume the 'oracle sqlplus instant client' is simply sqlplus.exe

I recently fixed this problem by setting the Oracle Service ID or SID into the environment.

You can test this by issuing the commands:

Set ORACLE_SID=VPN2TEST

and reissuing your sqlplus.exe connection command. If this works, and you want to make it permanant, (assuming windown7 or 2k8 server or greater), type:

setx /m ORACLE_SID VPN2TEST

This command will set the environment variable to survive a reboot, and will be available to all users of the machine.

RobW
  • 424
  • 2
  • 5