HiveBrain v1.2.0
Get Started
← Back to all entries
patternMinor

sqldeveloper ORA-12505. TNS: listener does not currently know of SID given in connect descriptor

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
sidconnectknowtnsdescriptorlistenersqldeveloperora12505does

Problem

There are similar questions asked and answered in this network related to the error message given in the question, however this problem is a little different from each.

I have installed oracle 12c in my ubuntu can successfully connect to my hr user with sqlplus hr/hr@pdborcl through command prompt.

oracle@ubuntu:~$ sqlplus hr/hr@pdborcl
SQL*Plus: Release 12.1.0.2.0 Production on Mon Nov 16 21:57:24 2015
Copyright (c) 1982, 2014, Oracle.  All rights reserved.
Last Successful login time: Mon Nov 16 2015 21:24:32 +05:45
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

SQL>show user;
USER is "HR"


I am however trying to use sqldeveloper for ease. In the create connection option in sqldeveloper when I give the following credentials

I get the following error.

ORA-12505. TNS: listener does not currently know of SID given in connect descriptor.

However connection with

Username: sys

Password:

SID:orcl

And same all other credentials work fine.

My tnsname.ora has

PDBORCL =
  (DESCRIPTION =
   (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
    (CONNECT_DATA =
    (SERVER = DEDICATED)
    (SERVICE_NAME = pdborcl)
   )
 )

ORCL =
 (DESCRIPTION =
  (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
  (CONNECT_DATA =
    (SERVER = DEDICATED)
    (SERVICE_NAME = orcl)
  )
 )

Solution

I had the same problem. And I solved it by using SERVICE NAME (an alias) instead of SID:

  1. Open file tnsnames.ora from your ORACLE_HOME folder. In case you don't know its location, do the following steps



Windows (open cmd)

> sqlplus // connect to sqlplus, login as sysdba
 as / sysdba
 // then type your password that you set in configuration setup step
 // next 3 lines used for getting ORACLE_HOME
 > var OHM varchar2(100);
 > EXEC dbms_system.get_env('ORACLE_HOME', :OHM);
 > PRINT OHM // ---> ORACLE_HOME


Linux (open Terminal Ctrl+Alt+T)

echo $ORACLE_HOME

tnsnames.ora is located at [Your_ORACLE_HOME]/Network/Admin. Open it with your editor.

  1. In tnsnames.ora file, look for the line which contains the SERVICE_NAME



  1. Select Service name and type above name, TEST success and you've done!

Code Snippets

> sqlplus // connect to sqlplus, login as sysdba
 as / sysdba
 // then type your password that you set in configuration setup step
 // next 3 lines used for getting ORACLE_HOME
 > var OHM varchar2(100);
 > EXEC dbms_system.get_env('ORACLE_HOME', :OHM);
 > PRINT OHM // ---> ORACLE_HOME

Context

StackExchange Database Administrators Q#121251, answer score: 5

Revisions (0)

No revisions yet.